diff --git a/.changeset/tricky-coats-shop.md b/.changeset/tricky-coats-shop.md new file mode 100644 index 0000000000..b3d45933a3 --- /dev/null +++ b/.changeset/tricky-coats-shop.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: skip unnecessary `$$legacy` flag diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/component.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/component.js index 44f943ddec..7c43f68a66 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/component.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/component.js @@ -298,7 +298,10 @@ export function build_component(node, component_name, context, anchor = context. push_prop(b.init('$$slots', b.object(serialized_slots))); } - if (!context.state.analysis.runes) { + if ( + !context.state.analysis.runes && + node.attributes.some((attribute) => attribute.type === 'BindDirective') + ) { push_prop(b.init('$$legacy', b.true)); } diff --git a/packages/svelte/tests/snapshot/samples/purity/_expected/client/index.svelte.js b/packages/svelte/tests/snapshot/samples/purity/_expected/client/index.svelte.js index 2863caba49..062e52f8cf 100644 --- a/packages/svelte/tests/snapshot/samples/purity/_expected/client/index.svelte.js +++ b/packages/svelte/tests/snapshot/samples/purity/_expected/client/index.svelte.js @@ -23,10 +23,6 @@ export default function Purity($$anchor) { var node = $.sibling($.sibling(p_1, true)); - Child(node, { - prop: encodeURIComponent(value), - $$legacy: true - }); - + Child(node, { prop: encodeURIComponent(value) }); $.append($$anchor, fragment); } \ No newline at end of file