File tree Expand file tree Collapse file tree 3 files changed +9
-16
lines changed
packages/svelte/tests/runtime-runes/samples/checkbox-binding-derived Expand file tree Collapse file tree 3 files changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export default test({
1010
1111 assert . htmlEqual (
1212 target . innerHTML ,
13- `<button>Add</button><label><input type="checkbox">\n1 </label><label><input type="checkbox">\nfoo </label>`
13+ `<button>Add</button><label><input type="checkbox"></label><label><input type="checkbox"></label>`
1414 ) ;
1515 }
1616} ) ;
Original file line number Diff line number Diff line change 11<script >
2- let { value = $bindable (), config } = $props ();
2+ let { value = $bindable () } = $props ();
33 </script >
44
55<label >
66 <input type ="checkbox" bind:checked ={value } />
7- {config .title }
87</label >
Original file line number Diff line number Diff line change 44 let foo = $state ({})
55
66 const schema = $state ({
7- properties: {
8- foo: true ,
9- },
7+ foo: true ,
108 })
119
12- function retrieveSchema (schema , value ) {
13- const cloned = { ... schema, properties : { ... schema . properties } }
14- for (const key of Object .keys (value )) {
15- cloned . properties [key] = key
10+ function retrieveSchema () {
11+ const cloned = { ... schema }
12+ for (const key of Object .keys (foo )) {
13+ cloned[key] = key
1614 }
1715 return cloned
1816 }
1917
20- const retrieved = $derived (retrieveSchema (schema, foo));
21- const required = $derived (new Set (retrieved .required ));
22- const properties = $derived (retrieved .properties );
23- const keys = $derived (Object .keys (properties));
18+ const keys = $derived (Object .keys (retrieveSchema ()));
2419 let nextKey = 1 ;
2520 </script >
2621
2924}}>Add</button >
3025
3126{#each keys as key (key )}
32- {@const config = { title: key , required: required .has (key ) }}
33- <Checkbox bind:value ={foo [key ]} {config } />
27+ <Checkbox bind:value ={foo [key ]} />
3428{/each }
You can’t perform that action at this time.
0 commit comments