mirror of https://github.com/sveltejs/svelte
update keyed each when key expression changes (#5447)
parent
c3b56a164e
commit
41d1656458
@ -0,0 +1,27 @@
|
||||
let count = 0;
|
||||
let value = 'foo';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value() {
|
||||
count++;
|
||||
return value;
|
||||
}
|
||||
},
|
||||
|
||||
html: `
|
||||
<div>foo</div>
|
||||
<div>foo</div>
|
||||
`,
|
||||
|
||||
test({ assert, component, target }) {
|
||||
value = 'bar';
|
||||
component.id = 1;
|
||||
|
||||
assert.equal(count, 4);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<div>bar</div>
|
||||
<div>bar</div>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
export let id = 0;
|
||||
export let value;
|
||||
</script>
|
||||
|
||||
{#each ['foo', 'bar'] as key (id + key)}
|
||||
<div>{value()}</div>
|
||||
{/each}
|
Loading…
Reference in new issue