From 2adfa2e92ebc8d207a31755184f0709c5a807c2b Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 20 Apr 2017 05:55:27 -0400 Subject: [PATCH] only call .update on yield fragment if it's present (#514) --- src/generators/dom/visitors/Component/Component.js | 10 ++++++---- .../samples/component-yield-static/Widget.html | 1 + .../samples/component-yield-static/_config.js | 12 ++++++++++++ .../runtime/samples/component-yield-static/main.html | 12 ++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 test/runtime/samples/component-yield-static/Widget.html create mode 100644 test/runtime/samples/component-yield-static/_config.js create mode 100644 test/runtime/samples/component-yield-static/main.html diff --git a/src/generators/dom/visitors/Component/Component.js b/src/generators/dom/visitors/Component/Component.js index c54945338def..9a2dbf0025ca 100644 --- a/src/generators/dom/visitors/Component/Component.js +++ b/src/generators/dom/visitors/Component/Component.js @@ -113,9 +113,11 @@ export default function visitComponent ( generator, block, state, node ) { `var ${yieldFragment} = ${childBlock.name}( ${params}, ${block.component} );` ); - block.builders.update.addLine( - `${yieldFragment}.update( changed, ${params} );` - ); + if ( childBlock.hasUpdateMethod ) { + block.builders.update.addLine( + `${yieldFragment}.update( changed, ${params} );` + ); + } componentInitProperties.push( `_yield: ${yieldFragment}`); } @@ -183,4 +185,4 @@ export default function visitComponent ( generator, block, state, node ) { block.builders.create.addBlock( local.create ); if ( !local.update.isEmpty() ) block.builders.update.addBlock( local.update ); -} \ No newline at end of file +} diff --git a/test/runtime/samples/component-yield-static/Widget.html b/test/runtime/samples/component-yield-static/Widget.html new file mode 100644 index 000000000000..25141c925499 --- /dev/null +++ b/test/runtime/samples/component-yield-static/Widget.html @@ -0,0 +1 @@ +{{yield}} diff --git a/test/runtime/samples/component-yield-static/_config.js b/test/runtime/samples/component-yield-static/_config.js new file mode 100644 index 000000000000..06bcd82882b0 --- /dev/null +++ b/test/runtime/samples/component-yield-static/_config.js @@ -0,0 +1,12 @@ +export default { + html: ` + Hello + `, + + test ( assert, component, target ) { + component.set( { name: 'World' } ); + assert.htmlEqual( target.innerHTML, ` + Hello World + ` ); + } +}; diff --git a/test/runtime/samples/component-yield-static/main.html b/test/runtime/samples/component-yield-static/main.html new file mode 100644 index 000000000000..5e2fffc76a46 --- /dev/null +++ b/test/runtime/samples/component-yield-static/main.html @@ -0,0 +1,12 @@ +Hello {{name}} + +