diff --git a/.changeset/wicked-doors-train.md b/.changeset/wicked-doors-train.md new file mode 100644 index 0000000000..28b3271046 --- /dev/null +++ b/.changeset/wicked-doors-train.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: add missing visitor for assignments during compilation 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 942bfab8c6..615fafd880 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 @@ -775,7 +775,7 @@ function serialize_inline_component(node, component_name, context) { const assignment = b.assignment('=', attribute.expression, b.id('$$value')); push_prop( b.set(attribute.name, [ - b.stmt(serialize_set_binding(assignment, context, () => assignment)) + b.stmt(serialize_set_binding(assignment, context, () => context.visit(assignment))) ]) ); } diff --git a/packages/svelte/tests/runtime-runes/samples/bind-state-property/CheckBox.svelte b/packages/svelte/tests/runtime-runes/samples/bind-state-property/CheckBox.svelte new file mode 100644 index 0000000000..172b699205 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/bind-state-property/CheckBox.svelte @@ -0,0 +1,5 @@ + + + diff --git a/packages/svelte/tests/runtime-runes/samples/bind-state-property/_config.js b/packages/svelte/tests/runtime-runes/samples/bind-state-property/_config.js new file mode 100644 index 0000000000..921fa71980 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/bind-state-property/_config.js @@ -0,0 +1,12 @@ +import { test } from '../../test'; + +export default test({ + html: `
\nChecked:\nfalse`, + + async test({ assert, target }) { + const input = target.querySelector('input'); + + await input?.click(); + assert.htmlEqual(target.innerHTML, `
\nChecked:\ntrue`); + } +}); diff --git a/packages/svelte/tests/runtime-runes/samples/bind-state-property/main.svelte b/packages/svelte/tests/runtime-runes/samples/bind-state-property/main.svelte new file mode 100644 index 0000000000..2a571c5dd1 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/bind-state-property/main.svelte @@ -0,0 +1,18 @@ + + +{#if true} + {@const obj = wrap()} + +{/if} +
+Checked: {checked}