-
-
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: ensure each block consistency to internal mutations to the colle…
…ction (#13614) * fix: ensure bind_checked defers mutation to ensure reactive graph stability * better fix * better fix * better fix * better fix * lint * simplify
- Loading branch information
Showing
5 changed files
with
64 additions
and
0 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: ensure each block consistency to internal mutations to the collection |
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
16 changes: 16 additions & 0 deletions
16
packages/svelte/tests/runtime-runes/samples/checkbox-binding-derived/_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,16 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
async test({ assert, target }) { | ||
const button = target.querySelector('button'); | ||
|
||
button?.click(); | ||
flushSync(); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
`<button>Add</button><label><input type="checkbox"></label><label><input type="checkbox"></label>` | ||
); | ||
} | ||
}); |
7 changes: 7 additions & 0 deletions
7
packages/svelte/tests/runtime-runes/samples/checkbox-binding-derived/checkbox.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,7 @@ | ||
<script> | ||
let { value = $bindable() } = $props(); | ||
</script> | ||
|
||
<label> | ||
<input type="checkbox" bind:checked={value} /> | ||
</label> |
28 changes: 28 additions & 0 deletions
28
packages/svelte/tests/runtime-runes/samples/checkbox-binding-derived/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,28 @@ | ||
<script> | ||
import Checkbox from './checkbox.svelte'; | ||
let foo = $state({}) | ||
const schema = $state({ | ||
foo: true, | ||
}) | ||
function retrieveSchema() { | ||
const cloned = { ...schema } | ||
for (const key of Object.keys(foo)) { | ||
cloned[key] = key | ||
} | ||
return cloned | ||
} | ||
const keys = $derived(Object.keys(retrieveSchema())); | ||
let nextKey = 1; | ||
</script> | ||
|
||
<button onclick={() => { | ||
foo[nextKey++] = true | ||
}}>Add</button> | ||
|
||
{#each keys as key (key)} | ||
<Checkbox bind:value={foo[key]} /> | ||
{/each} |