Skip to content

Commit c7692a3

Browse files
committed
fix: allow mutation of data and form props in Svelte 5
By doing `bind:data/form`, the layout/child components are allowed to mutate those properties Related sveltejs/svelte#9905
1 parent c749e85 commit c7692a3

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.changeset/selfish-seas-change.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sveltejs/kit": patch
3+
---
4+
5+
fix: allow mutation of data and form props in Svelte 5

packages/kit/src/core/sync/write_root.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,22 @@ export function write_root(manifest_data, output) {
2121

2222
let l = max_depth;
2323

24-
let pyramid = `<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} {form} />`;
24+
let pyramid = `<svelte:component this={constructors[${l}]} bind:this={components[${l}]} ${
25+
isSvelte5Plus() ? `bind:data={data_${l}} bind:form` : `data={data_${l}} {form}`
26+
} />`;
2527

2628
while (l--) {
2729
pyramid = dedent`
2830
{#if constructors[${l + 1}]}
29-
<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}}>
31+
<svelte:component this={constructors[${l}]} bind:this={components[${l}]} ${
32+
isSvelte5Plus() ? `bind:data={data_${l}}` : `data={data_${l}}`
33+
}>
3034
${pyramid}
3135
</svelte:component>
3236
{:else}
33-
<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} {form} />
37+
<svelte:component this={constructors[${l}]} bind:this={components[${l}]} ${
38+
isSvelte5Plus() ? `bind:data={data_${l}} bind:form` : `data={data_${l}} {form}`
39+
} />
3440
{/if}
3541
`;
3642
}

0 commit comments

Comments
 (0)