-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: invalidate store when mutated inside each block
fixes #10771
- Loading branch information
1 parent
0c1026f
commit 0758095
Showing
5 changed files
with
81 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"svelte": patch | ||
--- | ||
|
||
fix: invalidate store when mutated inside each block |
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
29 changes: 29 additions & 0 deletions
29
packages/svelte/tests/runtime-legacy/samples/binding-store-each/_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,29 @@ | ||
import { ok, test } from '../../test'; | ||
|
||
export default test({ | ||
skip_if_ssr: 'permanent', | ||
html: ` | ||
<input type="checkbox"> | ||
<input type="checkbox"> | ||
<input type="checkbox"> | ||
0 | ||
`, | ||
|
||
async test({ assert, target, window }) { | ||
const input = target.querySelector('input'); | ||
ok(input); | ||
|
||
input.checked = true; | ||
await input.dispatchEvent(new window.Event('change', { bubbles: true })); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<input type="checkbox"> | ||
<input type="checkbox"> | ||
<input type="checkbox"> | ||
1 | ||
` | ||
); | ||
} | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-legacy/samples/binding-store-each/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,12 @@ | ||
<script> | ||
import { derived, writable } from "svelte/store"; | ||
const checks = writable([false, false, false]) | ||
const countChecked = derived(checks, ($checks) => $checks.filter(Boolean).length) | ||
</script> | ||
|
||
{#each $checks as checked} | ||
<input type="checkbox" bind:checked /> | ||
{/each} | ||
|
||
{$countChecked} |