Skip to content

breaking: remove deep reactivity from non-bindable props #12484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/heavy-feet-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

breaking: remove deep reactivity from non-bindable props
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
`
);

Expand All @@ -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>
`
);
}
Expand Down
Loading