mirror of https://github.com/sveltejs/svelte
perform dirty check before updating keyed each blocks (#4413)
parent
7fdae5f8a8
commit
6250046c05
@ -0,0 +1,23 @@
|
||||
export default {
|
||||
html: `
|
||||
<button>Click Me</button>
|
||||
0
|
||||
<ul></ul>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
const button = target.querySelector("button");
|
||||
|
||||
const event = new window.MouseEvent("click");
|
||||
await button.dispatchEvent(event);
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>Click Me</button>
|
||||
1
|
||||
<ul></ul>
|
||||
`
|
||||
);
|
||||
}
|
||||
};
|
@ -0,0 +1,20 @@
|
||||
<script>
|
||||
let num = 0;
|
||||
let cards = [];
|
||||
|
||||
function click() {
|
||||
// updating cards via push should have no effect to the ul,
|
||||
// since its being mutated instead of reassigned
|
||||
cards.push(num++);
|
||||
}
|
||||
</script>
|
||||
<button on:click={click}>
|
||||
Click Me
|
||||
</button>
|
||||
|
||||
{num}
|
||||
<ul>
|
||||
{#each cards as c, i (i)}
|
||||
<li>{c}</li>
|
||||
{/each}
|
||||
</ul>
|
Loading…
Reference in new issue