Skip to content

Commit

Permalink
fix: use snippet as parent element of snippets childrens in validator (
Browse files Browse the repository at this point in the history
…#11463)

* fix: use snippet as parent element of snippets childrens in validator

* Update packages/svelte/src/compiler/phases/2-analyze/validation.js

* Update .changeset/wet-pears-remain.md

---------

Co-authored-by: Rich Harris <hello@rich-harris.dev>
  • Loading branch information
paoloricciuti and Rich-Harris committed May 8, 2024
1 parent 4fb4365 commit 70419da
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-pears-remain.md
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: skip parent element validation for snippet contents
2 changes: 2 additions & 0 deletions packages/svelte/src/compiler/phases/2-analyze/validation.js
Expand Up @@ -622,6 +622,8 @@ const validation = {
SnippetBlock(node, context) {
validate_block_not_empty(node.body, context);

context.next({ ...context.state, parent_element: null });

if (node.expression.name !== 'children') return;

const { path } = context;
Expand Down
@@ -0,0 +1 @@
[]
@@ -0,0 +1,10 @@
<table>
<tbody>
<tr>
{#snippet cell(v)}Value: {v}{/snippet}
{#each [1, 2, 3] as v}
<td>{@render cell(v)}</td>
{/each}
</tr>
</tbody>
</table>

0 comments on commit 70419da

Please sign in to comment.