Skip to content

Commit 83a5eaa

Browse files
authored
fix: skip comment nodes in snippet validation logic (#13936)
1 parent 37fa34c commit 83a5eaa

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

.changeset/shy-penguins-beg.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: skip comment nodes in snippet validation logic

packages/svelte/src/compiler/phases/2-analyze/visitors/SnippetBlock.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export function SnippetBlock(node, context) {
4646
) {
4747
if (
4848
parent.fragment.nodes.some(
49-
(node) => node.type !== 'SnippetBlock' && (node.type !== 'Text' || node.data.trim())
49+
(node) =>
50+
node.type !== 'SnippetBlock' &&
51+
(node.type !== 'Text' || node.data.trim()) &&
52+
node.type !== 'Comment'
5053
)
5154
) {
5255
e.snippet_conflict(node);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
const { children } = $props();
3+
</script>
4+
5+
{@render children()}
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: `The content`
5+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
import Child from "./Child.svelte"
3+
</script>
4+
5+
<Child>
6+
<!-- I'm just a poor comment -->
7+
{#snippet children()}
8+
The content
9+
{/snippet}
10+
</Child>

0 commit comments

Comments
 (0)