Merge pull request #515 from sveltejs/gh-514

only call .update on yield fragment if it's present (#514)
pull/517/head
Rich Harris 8 years ago committed by GitHub
commit 66929cd231

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

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

@ -0,0 +1,12 @@
<Widget>Hello</Widget> {{name}}
<script>
import Widget from './Widget.html';
export default {
components: { Widget },
data() {
return { name: '' };
}
};
</script>
Loading…
Cancel
Save