-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure bind:group works as intended with proxied state objects (#…
- Loading branch information
Showing
4 changed files
with
38 additions
and
2 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 bind:group works as intended with proxied state objects |
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
19 changes: 19 additions & 0 deletions
19
packages/svelte/tests/runtime-runes/samples/state-bind-group/_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,19 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
html: `<button>+</button><input type="checkbox" value="1"><input type="checkbox" value="2"><input type="checkbox" value="3">\n[]`, | ||
|
||
test({ assert, target }) { | ||
const btn = target.querySelector('button'); | ||
|
||
btn?.click(); | ||
flushSync(); | ||
|
||
assert.equal(target.querySelectorAll('input')[1].checked, true); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
`<button>+</button><input type="checkbox" value="1"><input type="checkbox" value="2"><input type="checkbox" value="3">\n["2"]` | ||
); | ||
} | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/state-bind-group/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> | ||
let checkboxes = $state([]); | ||
let values = ['1', '2', '3']; | ||
</script> | ||
|
||
<button onclick={() => checkboxes.push('2')}>+</button> | ||
|
||
{#each values as val, i} | ||
<input type="checkbox" value={val} bind:group={checkboxes} /> | ||
{/each} | ||
|
||
{JSON.stringify(checkboxes)} |