Merge pull request #1292 from sveltejs/gh-1291

allow keyed each block to have static content
pull/1295/head
Rich Harris 7 years ago committed by GitHub
commit 77aca3c69b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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')}
});

@ -0,0 +1,10 @@
export default {
data: {
x: [{ z: 1 }, { z: 2 }],
},
html: `
<p>does not change</p>
<p>does not change</p>
`
};

@ -0,0 +1,3 @@
{{#each x as y @z}}
<p>does not change</p>
{{/each}}
Loading…
Cancel
Save