From 45cea1fab54c2706c67e514e807e0a8a87166621 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 4 Jan 2017 12:03:47 -0500 Subject: [PATCH] make yield renderer names globally unique (#231) --- src/generators/dom/index.js | 2 +- src/generators/dom/visitors/Component.js | 2 +- .../Widget.html | 1 + .../component-yield-multiple-in-if/_config.js | 14 +++++++++++ .../component-yield-multiple-in-if/main.html | 23 +++++++++++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 test/generator/component-yield-multiple-in-if/Widget.html create mode 100644 test/generator/component-yield-multiple-in-if/_config.js create mode 100644 test/generator/component-yield-multiple-in-if/main.html diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js index 88dcb91faa34..929d737700a5 100644 --- a/src/generators/dom/index.js +++ b/src/generators/dom/index.js @@ -83,7 +83,7 @@ class DomGenerator extends Generator { properties.addBlock( deindent` teardown: function ( detach ) { ${fragment.builders.teardown} - }, + } ` ); } diff --git a/src/generators/dom/visitors/Component.js b/src/generators/dom/visitors/Component.js index 50bcc984660f..7f3e4c665306 100644 --- a/src/generators/dom/visitors/Component.js +++ b/src/generators/dom/visitors/Component.js @@ -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 ); diff --git a/test/generator/component-yield-multiple-in-if/Widget.html b/test/generator/component-yield-multiple-in-if/Widget.html new file mode 100644 index 000000000000..2dddb1946f7c --- /dev/null +++ b/test/generator/component-yield-multiple-in-if/Widget.html @@ -0,0 +1 @@ +

{{yield}}

diff --git a/test/generator/component-yield-multiple-in-if/_config.js b/test/generator/component-yield-multiple-in-if/_config.js new file mode 100644 index 000000000000..7ba8c6c497f9 --- /dev/null +++ b/test/generator/component-yield-multiple-in-if/_config.js @@ -0,0 +1,14 @@ +export default { + solo: true, + + html: ` +

Hello

+ `, + + test ( assert, component, target ) { + component.set({ arriving: false }); + assert.htmlEqual( target.innerHTML, `

Goodbye

` ); + + component.teardown(); + } +}; diff --git a/test/generator/component-yield-multiple-in-if/main.html b/test/generator/component-yield-multiple-in-if/main.html new file mode 100644 index 000000000000..e1d380e6476f --- /dev/null +++ b/test/generator/component-yield-multiple-in-if/main.html @@ -0,0 +1,23 @@ +
+ {{#if arriving}} + Hello + {{else}} + Goodbye + {{/if}} +
+ +