Skip to content

Commit

Permalink
Merge pull request #617 from sveltejs/fix-magic-string-deprecation
Browse files Browse the repository at this point in the history
Update for magic-string .overwrite API change
  • Loading branch information
Rich-Harris authored Jun 3, 2017
2 parents 6bfddc2 + 0361694 commit f016a84
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/generators/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class Generator {
}

if ( node.type === 'ThisExpression' ) {
if ( lexicalDepth === 0 && context ) code.overwrite( node.start, node.end, context, true );
if ( lexicalDepth === 0 && context ) code.overwrite( node.start, node.end, context, { storeName: true, contentOnly: false } );
}

else if ( isReference( node, parent ) ) {
Expand All @@ -129,7 +129,7 @@ export default class Generator {
const contextName = contexts.get( name );
if ( contextName !== name ) {
// this is true for 'reserved' names like `state` and `component`
code.overwrite( node.start, node.start + name.length, contextName, true );
code.overwrite( node.start, node.start + name.length, contextName, { storeName: true, contentOnly: false } );
}

if ( !~usedContexts.indexOf( name ) ) usedContexts.push( name );
Expand Down Expand Up @@ -426,13 +426,13 @@ export default class Generator {
// Remove these after version 2
if ( templateProperties.onrender ) {
const { key } = templateProperties.onrender;
this.code.overwrite( key.start, key.end, 'oncreate', true );
this.code.overwrite( key.start, key.end, 'oncreate', { storeName: true, contentOnly: false } );
templateProperties.oncreate = templateProperties.onrender;
}

if ( templateProperties.onteardown ) {
const { key } = templateProperties.onteardown;
this.code.overwrite( key.start, key.end, 'ondestroy', true );
this.code.overwrite( key.start, key.end, 'ondestroy', { storeName: true, contentOnly: false } );
templateProperties.ondestroy = templateProperties.onteardown;
}

Expand Down

0 comments on commit f016a84

Please sign in to comment.