Skip to content

Commit e0e50cc

Browse files
committed
simplify
1 parent a957197 commit e0e50cc

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

packages/svelte/tests/runtime-runes/samples/checkbox-binding-derived/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
});
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
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>

packages/svelte/tests/runtime-runes/samples/checkbox-binding-derived/main.svelte

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,18 @@
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

@@ -29,6 +24,5 @@
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}

0 commit comments

Comments
 (0)