fix: use snippet as parent element of snippets childrens in validator (#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>
pull/11521/head
Paolo Ricciuti 8 months ago committed by GitHub
parent 4fb4365567
commit 70419daf5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: skip parent element validation for snippet contents

@ -622,6 +622,8 @@ const validation = {
SnippetBlock(node, context) { SnippetBlock(node, context) {
validate_block_not_empty(node.body, context); validate_block_not_empty(node.body, context);
context.next({ ...context.state, parent_element: null });
if (node.expression.name !== 'children') return; if (node.expression.name !== 'children') return;
const { path } = context; const { path } = context;

@ -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>
Loading…
Cancel
Save