Skip to content

Commit 1b5f6af

Browse files
fix: destructuring snippet arguments (#16068)
1 parent b851b54 commit 1b5f6af

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

.changeset/violet-actors-teach.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: destructuring snippet arguments

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function SnippetBlock(node, context) {
5757
for (const path of paths) {
5858
const name = /** @type {Identifier} */ (path.node).name;
5959
const needs_derived = path.has_default_value; // to ensure that default value is only called once
60-
const fn = b.thunk(/** @type {Expression} */ (context.visit(path.expression)));
60+
const fn = b.thunk(/** @type {Expression} */ (context.visit(path.expression, child_state)));
6161

6262
declarations.push(b.let(path.node, needs_derived ? b.call('$.derived_safe_equal', fn) : fn));
6363

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: `a`
5+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script>
2+
let array = $state(['a', 'b', 'c'])
3+
</script>
4+
5+
{#snippet content([x])}
6+
{x}
7+
{/snippet}
8+
9+
{@render content(array)}

0 commit comments

Comments
 (0)