Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/violet-actors-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: destructuring snippet arguments
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function SnippetBlock(node, context) {
for (const path of paths) {
const name = /** @type {Identifier} */ (path.node).name;
const needs_derived = path.has_default_value; // to ensure that default value is only called once
const fn = b.thunk(/** @type {Expression} */ (context.visit(path.expression)));
const fn = b.thunk(/** @type {Expression} */ (context.visit(path.expression, child_state)));

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

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

export default test({
html: `a`
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script>
let array = $state(['a', 'b', 'c'])
</script>

{#snippet content([x])}
{x}
{/snippet}

{@render content(array)}