From 58d5c2040acd8be1607bf3092ee7dd8cac5df257 Mon Sep 17 00:00:00 2001 From: pk Date: Wed, 7 Mar 2018 22:38:48 +0100 Subject: [PATCH 1/3] failing test for #1217 --- .../samples/each-block-array-literal/_config.js | 17 +++++++++++++++++ .../samples/each-block-array-literal/main.html | 11 +++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/runtime/samples/each-block-array-literal/_config.js create mode 100644 test/runtime/samples/each-block-array-literal/main.html diff --git a/test/runtime/samples/each-block-array-literal/_config.js b/test/runtime/samples/each-block-array-literal/_config.js new file mode 100644 index 000000000000..7fcc47703854 --- /dev/null +++ b/test/runtime/samples/each-block-array-literal/_config.js @@ -0,0 +1,17 @@ +export default { + html: ` + + `, + + test ( assert, component, target ) { + assert.htmlEqual( target.innerHTML, ` + + `); + + const button = target.querySelector( 'button' ); + const event = new window.MouseEvent( 'click' ); + + button.dispatchEvent( event ); + assert.equal( component.get( 'clicked' ), 'racoon' ); + }, +}; diff --git a/test/runtime/samples/each-block-array-literal/main.html b/test/runtime/samples/each-block-array-literal/main.html new file mode 100644 index 000000000000..8dca00c92e40 --- /dev/null +++ b/test/runtime/samples/each-block-array-literal/main.html @@ -0,0 +1,11 @@ +{{#each ['racoon', 'eagle'] as animal}} + +{{/each}} + + From ddd67dd844081c376794988415db327fb0b43ed5 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 8 Mar 2018 21:53:50 -0500 Subject: [PATCH 2/3] add each_value to contextProps - fixes #1206 --- src/generators/nodes/EachBlock.ts | 1 + .../each-block-array-literal/_config.js | 18 ++++++++++-------- .../samples/each-block-array-literal/main.html | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/generators/nodes/EachBlock.ts b/src/generators/nodes/EachBlock.ts index 97671c37b079..e75e1722aeae 100644 --- a/src/generators/nodes/EachBlock.ts +++ b/src/generators/nodes/EachBlock.ts @@ -75,6 +75,7 @@ export default class EachBlock extends Node { } this.contextProps = [ + `${this.block.listName}: ${this.block.listName}`, `${this.context}: ${this.block.listName}[#i]`, `${this.block.indexName}: #i` ]; diff --git a/test/runtime/samples/each-block-array-literal/_config.js b/test/runtime/samples/each-block-array-literal/_config.js index 7fcc47703854..bc36cdbe0e5f 100644 --- a/test/runtime/samples/each-block-array-literal/_config.js +++ b/test/runtime/samples/each-block-array-literal/_config.js @@ -1,17 +1,19 @@ export default { html: ` - + + `, - test ( assert, component, target ) { - assert.htmlEqual( target.innerHTML, ` - + test(assert, component, target) { + assert.htmlEqual(target.innerHTML,` + + `); - const button = target.querySelector( 'button' ); - const event = new window.MouseEvent( 'click' ); + const button = target.querySelector('button'); + const event = new window.MouseEvent('click'); - button.dispatchEvent( event ); - assert.equal( component.get( 'clicked' ), 'racoon' ); + button.dispatchEvent(event); + assert.equal(component.get('clicked'), 'racoon'); }, }; diff --git a/test/runtime/samples/each-block-array-literal/main.html b/test/runtime/samples/each-block-array-literal/main.html index 8dca00c92e40..8c55e9461299 100644 --- a/test/runtime/samples/each-block-array-literal/main.html +++ b/test/runtime/samples/each-block-array-literal/main.html @@ -1,5 +1,5 @@ {{#each ['racoon', 'eagle'] as animal}} - + {{/each}}