fix: handle falsy prop aliases correctly (#11539)

fixes #10854
pull/11544/head
Simon H 1 year ago committed by GitHub
parent 4ea8a5e36b
commit 65223363e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: handle falsy prop aliases correctly

@ -967,7 +967,7 @@ const runes_scope_tweaker = {
const alias = const alias =
property.key.type === 'Identifier' property.key.type === 'Identifier'
? property.key.name ? property.key.name
: /** @type {string} */ (/** @type {import('estree').Literal} */ (property.key).value); : String(/** @type {import('estree').Literal} */ (property.key).value);
let initial = property.value.type === 'AssignmentPattern' ? property.value.right : null; let initial = property.value.type === 'AssignmentPattern' ? property.value.right : null;
const binding = /** @type {import('#compiler').Binding} */ (state.scope.get(name)); const binding = /** @type {import('#compiler').Binding} */ (state.scope.get(name));

@ -0,0 +1,5 @@
<script>
let { 0: zero, 'ysc%%gibberish': one } = $props();
</script>
{zero} {one}

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

@ -0,0 +1,5 @@
<script>
import Child from './Child.svelte';
</script>
<Child 0={0} ysc%%gibberish={1} />
Loading…
Cancel
Save