Skip to content

Commit

Permalink
Merge pull request #242 from sveltejs/gh-231
Browse files Browse the repository at this point in the history
make yield renderer names globally unique
  • Loading branch information
Rich-Harris authored Jan 4, 2017
2 parents 9eee57e + 45cea1f commit 00db841
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/generators/dom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class DomGenerator extends Generator {
properties.addBlock( deindent`
teardown: function ( detach ) {
${fragment.builders.teardown}
},
}
` );
}

Expand Down
2 changes: 1 addition & 1 deletion src/generators/dom/visitors/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default {

// Component has children, put them in a separate {{yield}} block
if ( hasChildren ) {
const yieldName = generator.current.getUniqueName( `render${name}YieldFragment` );
const yieldName = generator.getUniqueName( `render${name}YieldFragment` );

generator.generateBlock( node, yieldName );

Expand Down
1 change: 1 addition & 0 deletions test/generator/component-yield-multiple-in-if/Widget.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p class='widget'>{{yield}}</p>
14 changes: 14 additions & 0 deletions test/generator/component-yield-multiple-in-if/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
solo: true,

html: `
<div><p class='widget'>Hello</p></div>
`,

test ( assert, component, target ) {
component.set({ arriving: false });
assert.htmlEqual( target.innerHTML, `<div><p class='widget'>Goodbye</p></div>` );

component.teardown();
}
};
23 changes: 23 additions & 0 deletions test/generator/component-yield-multiple-in-if/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div>
{{#if arriving}}
<Widget>Hello</Widget>
{{else}}
<Widget>Goodbye</Widget>
{{/if}}
</div>

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

export default {
data () {
return {
arriving: true
}
},

components: {
Widget
}
};
</script>

0 comments on commit 00db841

Please sign in to comment.