forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perform dirty check before updating keyed each blocks (sveltejs#4413)
- Loading branch information
1 parent
00c8058
commit 97b0798
Showing
7 changed files
with
74 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
test/runtime/samples/each-block-keyed-dynamic-2/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
` | ||
); | ||
} | ||
}; |
20 changes: 20 additions & 0 deletions
20
test/runtime/samples/each-block-keyed-dynamic-2/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |