Skip to content

Commit ea22840

Browse files
authored
breaking: remove deep reactivity from non-bindable props (#12484)
* breaking: remove deep reactivity from non-bindable props * breaking: remove deep reactivity from non-bindable props * lint
1 parent 44d72d6 commit ea22840

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

.changeset/heavy-feet-attend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
breaking: remove deep reactivity from non-bindable props

packages/svelte/src/compiler/phases/3-transform/client/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ export function serialize_set_binding(node, context, fallback, prefix, options)
336336
left,
337337
context.state.analysis.runes &&
338338
!options?.skip_proxy_and_freeze &&
339-
should_proxy_or_freeze(value, context.state.scope)
339+
should_proxy_or_freeze(value, context.state.scope) &&
340+
binding.kind === 'bindable_prop'
340341
? serialize_proxy_reassignment(value, left_name, state)
341342
: value
342343
);

packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,11 @@ export const javascript_visitors_runes = {
276276
/** @type {import('estree').Expression} */ (visit(binding.initial));
277277
// We're adding proxy here on demand and not within the prop runtime function so that
278278
// people not using proxied state anywhere in their code don't have to pay the additional bundle size cost
279-
if (initial && binding.mutated && should_proxy_or_freeze(initial, state.scope)) {
279+
if (
280+
initial &&
281+
binding.kind === 'bindable_prop' &&
282+
should_proxy_or_freeze(initial, state.scope)
283+
) {
280284
initial = b.call('$.proxy', initial);
281285
}
282286

packages/svelte/tests/runtime-runes/samples/props-default-reactivity/_config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export default test({
6363
`
6464
<button>mutate: 3</button>
6565
<button>reassign: 3</button>
66-
<button>mutate: 1</button>
67-
<button>reassign: 1</button>
66+
<button>mutate: 0</button>
67+
<button>reassign: 0</button>
6868
`
6969
);
7070

@@ -91,8 +91,8 @@ export default test({
9191
`
9292
<button>mutate: 3</button>
9393
<button>reassign: 3</button>
94-
<button>mutate: 3</button>
95-
<button>reassign: 3</button>
94+
<button>mutate: 2</button>
95+
<button>reassign: 2</button>
9696
`
9797
);
9898
}

0 commit comments

Comments
 (0)