fix: skip comment nodes in snippet validation logic (#13936)

pull/13920/head
Dominic Gannaway 2 weeks ago committed by GitHub
parent 37fa34c4ad
commit 83a5eaac8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: skip comment nodes in snippet validation logic

@ -46,7 +46,10 @@ export function SnippetBlock(node, context) {
) {
if (
parent.fragment.nodes.some(
(node) => node.type !== 'SnippetBlock' && (node.type !== 'Text' || node.data.trim())
(node) =>
node.type !== 'SnippetBlock' &&
(node.type !== 'Text' || node.data.trim()) &&
node.type !== 'Comment'
)
) {
e.snippet_conflict(node);

@ -0,0 +1,5 @@
<script>
const { children } = $props();
</script>
{@render children()}

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
html: `The content`
});

@ -0,0 +1,10 @@
<script>
import Child from "./Child.svelte"
</script>
<Child>
<!-- I'm just a poor comment -->
{#snippet children()}
The content
{/snippet}
</Child>
Loading…
Cancel
Save