Skip to content

Commit

Permalink
fix: handle falsy prop aliases correctly (#11539)
Browse files Browse the repository at this point in the history
fixes #10854
  • Loading branch information
dummdidumm authored May 10, 2024
1 parent 4ea8a5e commit 6522336
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/strong-apricots-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: handle falsy prop aliases correctly
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/phases/2-analyze/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ const runes_scope_tweaker = {
const alias =
property.key.type === 'Identifier'
? 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;

const binding = /** @type {import('#compiler').Binding} */ (state.scope.get(name));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
let { 0: zero, 'ysc%%gibberish': one } = $props();
</script>

{zero} {one}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { test } from '../../test';

export default test({
html: `0 1`
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
import Child from './Child.svelte';
</script>

<Child 0={0} ysc%%gibberish={1} />

0 comments on commit 6522336

Please sign in to comment.