diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js index fd4b4e4a04..773a28f8d4 100644 --- a/src/generators/dom/index.js +++ b/src/generators/dom/index.js @@ -71,6 +71,8 @@ class DomGenerator extends Generator { } else { properties.addBlock( deindent` update: function ( changed, ${fragment.params} ) { + var __tmp; + ${fragment.builders.update} }, ` ); diff --git a/src/generators/dom/visitors/MustacheTag.js b/src/generators/dom/visitors/MustacheTag.js index d22bb5c243..9983cec6b0 100644 --- a/src/generators/dom/visitors/MustacheTag.js +++ b/src/generators/dom/visitors/MustacheTag.js @@ -7,13 +7,13 @@ export default { generator.addSourcemapLocations( node.expression ); const { snippet } = generator.contextualise( node.expression ); + generator.current.builders.init.addLine( `var last_${name} = ${snippet}` ); + generator.addElement( name, `createText( last_${name} )`, true ); generator.uses.createText = true; - generator.addElement( name, `createText( ${snippet} )`, true ); - generator.current.builders.init.addLine(`var last_${name} = ${snippet}`); generator.current.builders.update.addBlock( deindent` - if (${snippet} !== last_${name}) { - ${name}.data = last_${name} = ${snippet}; + if ( ( __tmp = ${snippet} ) !== last_${name} ) { + ${name}.data = last_${name} = __tmp; } ` ); }