Skip to content

Commit

Permalink
Merge pull request #1292 from sveltejs/gh-1291
Browse files Browse the repository at this point in the history
allow keyed each block to have static content
  • Loading branch information
Rich-Harris authored Mar 30, 2018
2 parents c943a86 + 01a10d9 commit 77aca3c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/generators/nodes/EachBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')}
});
Expand Down
10 changes: 10 additions & 0 deletions test/runtime/samples/each-block-keyed-static/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
data: {
x: [{ z: 1 }, { z: 2 }],
},

html: `
<p>does not change</p>
<p>does not change</p>
`
};
3 changes: 3 additions & 0 deletions test/runtime/samples/each-block-keyed-static/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{#each x as y @z}}
<p>does not change</p>
{{/each}}

0 comments on commit 77aca3c

Please sign in to comment.