Skip to content

Commit

Permalink
fix: skip comment nodes in snippet validation logic (#13936)
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm authored Oct 25, 2024
1 parent 37fa34c commit 83a5eaa
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/shy-penguins-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: skip comment nodes in snippet validation logic
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
const { children } = $props();
</script>

{@render children()}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { test } from '../../test';

export default test({
html: `The content`
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script>
import Child from "./Child.svelte"
</script>

<Child>
<!-- I'm just a poor comment -->
{#snippet children()}
The content
{/snippet}
</Child>

0 comments on commit 83a5eaa

Please sign in to comment.