use temporary variable when determining whether to update text tag

pull/294/head
Rich-Harris 8 years ago
parent b36f258dfe
commit d727ab48d0

@ -71,6 +71,8 @@ class DomGenerator extends Generator {
} else {
properties.addBlock( deindent`
update: function ( changed, ${fragment.params} ) {
var __tmp;
${fragment.builders.update}
},
` );

@ -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;
}
` );
}

Loading…
Cancel
Save