diff --git a/.changeset/itchy-kings-deliver.md b/.changeset/itchy-kings-deliver.md new file mode 100644 index 0000000000..1a188b77f3 --- /dev/null +++ b/.changeset/itchy-kings-deliver.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +Fix issue with assigning prop values as defaults of other props 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 41ce98de49..e4de622649 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 @@ -195,6 +195,9 @@ export const javascript_visitors_runes = { id = property.value.left; initial = property.value.right; } + initial = initial + ? /** @type {import('estree').Expression} */ (visit(initial)) + : undefined; assert.equal(id.type, 'Identifier'); diff --git a/packages/svelte/tests/runtime-runes/samples/assign-prop-to-prop/Test.svelte b/packages/svelte/tests/runtime-runes/samples/assign-prop-to-prop/Test.svelte new file mode 100644 index 0000000000..0bf0649b9e --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/assign-prop-to-prop/Test.svelte @@ -0,0 +1,9 @@ + + +

{a}

+

{b}

+

{c}

+

{d}

\ No newline at end of file diff --git a/packages/svelte/tests/runtime-runes/samples/assign-prop-to-prop/_config.js b/packages/svelte/tests/runtime-runes/samples/assign-prop-to-prop/_config.js new file mode 100644 index 0000000000..f68a56cfbc --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/assign-prop-to-prop/_config.js @@ -0,0 +1,5 @@ +import { test } from '../../test'; + +export default test({ + html: `

5

5

25

65

` +}); diff --git a/packages/svelte/tests/runtime-runes/samples/assign-prop-to-prop/main.svelte b/packages/svelte/tests/runtime-runes/samples/assign-prop-to-prop/main.svelte new file mode 100644 index 0000000000..0ff0ef524e --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/assign-prop-to-prop/main.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file