diff --git a/.changeset/heavy-feet-attend.md b/.changeset/heavy-feet-attend.md new file mode 100644 index 0000000000..24b3519c9a --- /dev/null +++ b/.changeset/heavy-feet-attend.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +breaking: remove deep reactivity from non-bindable props diff --git a/packages/svelte/src/compiler/phases/3-transform/client/utils.js b/packages/svelte/src/compiler/phases/3-transform/client/utils.js index e77ee236ef..ea0d3d55e7 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/utils.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/utils.js @@ -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 ); diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js index 4588f71d47..88c04bc866 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js @@ -276,7 +276,7 @@ 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); } diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js index f5bd0af8da..792734a457 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js @@ -776,6 +776,7 @@ function serialize_inline_component(node, component_name, context, anchor = cont push_prop(b.init(attribute.name, value)); } } else if (attribute.type === 'BindDirective') { + debugger if (attribute.name === 'this') { bind_this = attribute.expression; } else { diff --git a/packages/svelte/tests/runtime-runes/samples/props-default-reactivity/_config.js b/packages/svelte/tests/runtime-runes/samples/props-default-reactivity/_config.js index 4ebb27fc9a..5eff145cb7 100644 --- a/packages/svelte/tests/runtime-runes/samples/props-default-reactivity/_config.js +++ b/packages/svelte/tests/runtime-runes/samples/props-default-reactivity/_config.js @@ -63,8 +63,8 @@ export default test({ ` - - + + ` ); @@ -91,8 +91,8 @@ export default test({ ` - - + + ` ); }