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
pull/12493/head
Dominic Gannaway 5 months ago committed by GitHub
parent 44d72d69cf
commit ea22840e8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
breaking: remove deep reactivity from non-bindable props

@ -336,7 +336,8 @@ export function serialize_set_binding(node, context, fallback, prefix, options)
left,
context.state.analysis.runes &&
!options?.skip_proxy_and_freeze &&
should_proxy_or_freeze(value, context.state.scope)
should_proxy_or_freeze(value, context.state.scope) &&
binding.kind === 'bindable_prop'
? serialize_proxy_reassignment(value, left_name, state)
: value
);

@ -276,7 +276,11 @@ export const javascript_visitors_runes = {
/** @type {import('estree').Expression} */ (visit(binding.initial));
// We're adding proxy here on demand and not within the prop runtime function so that
// people not using proxied state anywhere in their code don't have to pay the additional bundle size cost
if (initial && binding.mutated && should_proxy_or_freeze(initial, state.scope)) {
if (
initial &&
binding.kind === 'bindable_prop' &&
should_proxy_or_freeze(initial, state.scope)
) {
initial = b.call('$.proxy', initial);
}

@ -63,8 +63,8 @@ export default test({
`
<button>mutate: 3</button>
<button>reassign: 3</button>
<button>mutate: 1</button>
<button>reassign: 1</button>
<button>mutate: 0</button>
<button>reassign: 0</button>
`
);
@ -91,8 +91,8 @@ export default test({
`
<button>mutate: 3</button>
<button>reassign: 3</button>
<button>mutate: 3</button>
<button>reassign: 3</button>
<button>mutate: 2</button>
<button>reassign: 2</button>
`
);
}

Loading…
Cancel
Save