mirror of https://github.com/sveltejs/svelte
Merge pull request #1381 from sveltejs/gh-703
allow arbitrary expressions in each block keyspull/1388/head
commit
2c3f846623
@ -0,0 +1,31 @@
|
||||
export default {
|
||||
data: {
|
||||
words: ['foo', 'bar', 'baz']
|
||||
},
|
||||
|
||||
html: `
|
||||
<p>foo</p>
|
||||
<p>bar</p>
|
||||
<p>baz</p>
|
||||
`,
|
||||
|
||||
test(assert, component, target) {
|
||||
const [p1, p2, p3] = target.querySelectorAll('p');
|
||||
|
||||
component.set({
|
||||
words: ['foo', 'baz'],
|
||||
});
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<p>foo</p>
|
||||
<p>baz</p>
|
||||
`);
|
||||
|
||||
const [p4, p5] = target.querySelectorAll('p');
|
||||
|
||||
assert.ok(!target.contains(p2), '<p> element should be removed');
|
||||
|
||||
assert.equal(p1, p4, 'first <p> element should be retained');
|
||||
assert.equal(p3, p5, 'last <p> element should be retained');
|
||||
},
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
{#each words as word (word)}
|
||||
<p>{word}</p>
|
||||
{/each}
|
Loading…
Reference in new issue