Skip to content

Commit 5dffe71

Browse files
authored
fix: issue with assiging prop values as defaults of other props (#9985)
* Fix issue on assiging prop values as defaults of other props * Prettier * Add changeset
1 parent 547ab93 commit 5dffe71

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

.changeset/itchy-kings-deliver.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
Fix issue with assigning prop values as defaults of other props

packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ export const javascript_visitors_runes = {
195195
id = property.value.left;
196196
initial = property.value.right;
197197
}
198+
initial = initial
199+
? /** @type {import('estree').Expression} */ (visit(initial))
200+
: undefined;
198201

199202
assert.equal(id.type, 'Identifier');
200203

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script>
2+
let z = 8;
3+
let { a, b = a, c = b * b, d = z * b + c } = $props();
4+
</script>
5+
6+
<p>{a}</p>
7+
<p>{b}</p>
8+
<p>{c}</p>
9+
<p>{d}</p>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: `<p>5</p><p>5</p><p>25</p><p>65</p>`
5+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
import Test from './Test.svelte'
3+
</script>
4+
5+
<Test a={5} />

0 commit comments

Comments
 (0)