Skip to content

Commit

Permalink
only call .update on yield fragment if it's present (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Apr 20, 2017
1 parent 1fd3c21 commit 2adfa2e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/generators/dom/visitors/Component/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
Expand Down Expand Up @@ -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 );
}
}
1 change: 1 addition & 0 deletions test/runtime/samples/component-yield-static/Widget.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<b>{{yield}}</b>
12 changes: 12 additions & 0 deletions test/runtime/samples/component-yield-static/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
html: `
<b>Hello</b>
`,

test ( assert, component, target ) {
component.set( { name: 'World' } );
assert.htmlEqual( target.innerHTML, `
<b>Hello</b> World
` );
}
};
12 changes: 12 additions & 0 deletions test/runtime/samples/component-yield-static/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Widget>Hello</Widget> {{name}}

<script>
import Widget from './Widget.html';

export default {
components: { Widget },
data() {
return { name: '' };
}
};
</script>

0 comments on commit 2adfa2e

Please sign in to comment.