From 2c670a43acf9f6625df20041a3302d2be37778ab Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Fri, 30 Mar 2018 15:44:27 -0400 Subject: [PATCH 1/2] allow keyed each block to have static content - fixes #1291 --- src/generators/nodes/EachBlock.ts | 2 +- .../samples/each-block-keyed-static/_config.js | 12 ++++++++++++ .../samples/each-block-keyed-static/main.html | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/each-block-keyed-static/_config.js create mode 100644 test/runtime/samples/each-block-keyed-static/main.html diff --git a/src/generators/nodes/EachBlock.ts b/src/generators/nodes/EachBlock.ts index 1eb1d8cb7a86..388474bb31b6 100644 --- a/src/generators/nodes/EachBlock.ts +++ b/src/generators/nodes/EachBlock.ts @@ -296,7 +296,7 @@ export default class EachBlock extends Node { block.builders.update.addBlock(deindent` var ${each_block_value} = ${snippet}; - ${blocks} = @updateKeyedEach(${blocks}, #component, changed, "${this.key}", ${dynamic}, ${each_block_value}, ${lookup}, ${updateMountNode}, ${String(this.block.hasOutroMethod)}, ${create_each_block}, "${mountOrIntro}", function(#i) { + ${blocks} = @updateKeyedEach(${blocks}, #component, changed, "${this.key}", ${dynamic ? '1' : '0'}, ${each_block_value}, ${lookup}, ${updateMountNode}, ${String(this.block.hasOutroMethod)}, ${create_each_block}, "${mountOrIntro}", function(#i) { return @assign(@assign({}, state), { ${this.contextProps.join(',\n')} }); diff --git a/test/runtime/samples/each-block-keyed-static/_config.js b/test/runtime/samples/each-block-keyed-static/_config.js new file mode 100644 index 000000000000..7f7dcc6a3565 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-static/_config.js @@ -0,0 +1,12 @@ +export default { + solo: true, + + data: { + x: [{ z: 1 }, { z: 2 }], + }, + + html: ` +

does not change

+

does not change

+ ` +}; diff --git a/test/runtime/samples/each-block-keyed-static/main.html b/test/runtime/samples/each-block-keyed-static/main.html new file mode 100644 index 000000000000..d9180cba65d7 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-static/main.html @@ -0,0 +1,3 @@ +{{#each x as y @z}} +

does not change

+{{/each}} From 01a10d951132dcf91e19e7de5ccb5486984992aa Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Fri, 30 Mar 2018 15:48:23 -0400 Subject: [PATCH 2/2] argh, need a precommit check for this --- test/runtime/samples/each-block-keyed-static/_config.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/runtime/samples/each-block-keyed-static/_config.js b/test/runtime/samples/each-block-keyed-static/_config.js index 7f7dcc6a3565..7166854cd647 100644 --- a/test/runtime/samples/each-block-keyed-static/_config.js +++ b/test/runtime/samples/each-block-keyed-static/_config.js @@ -1,6 +1,4 @@ export default { - solo: true, - data: { x: [{ z: 1 }, { z: 2 }], },