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
pull/10008/head
Nguyen Tran 1 year ago committed by GitHub
parent 547ab932a8
commit 5dffe715d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
Fix issue with assigning prop values as defaults of other props

@ -195,6 +195,9 @@ export const javascript_visitors_runes = {
id = property.value.left; id = property.value.left;
initial = property.value.right; initial = property.value.right;
} }
initial = initial
? /** @type {import('estree').Expression} */ (visit(initial))
: undefined;
assert.equal(id.type, 'Identifier'); assert.equal(id.type, 'Identifier');

@ -0,0 +1,9 @@
<script>
let z = 8;
let { a, b = a, c = b * b, d = z * b + c } = $props();
</script>
<p>{a}</p>
<p>{b}</p>
<p>{c}</p>
<p>{d}</p>

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
html: `<p>5</p><p>5</p><p>25</p><p>65</p>`
});

@ -0,0 +1,5 @@
<script>
import Test from './Test.svelte'
</script>
<Test a={5} />
Loading…
Cancel
Save