Skip to content

Commit dfa97a5

Browse files
feat: allow every children in template tags (#15007)
* feat: allow every children in `template` tags * Update .changeset/dry-mails-return.md --------- Co-authored-by: Rich Harris <[email protected]>
1 parent a1698c6 commit dfa97a5

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

.changeset/dry-mails-return.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': minor
3+
---
4+
5+
feat: allow `<template>` elements to contain any child

packages/svelte/src/html-tree-validation.js

+2
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ export function is_tag_valid_with_ancestor(child_tag, ancestors, child_loc, ance
186186
export function is_tag_valid_with_parent(child_tag, parent_tag, child_loc, parent_loc) {
187187
if (child_tag.includes('-') || parent_tag?.includes('-')) return null; // custom elements can be anything
188188

189+
if (parent_tag === 'template') return null; // no errors or warning should be thrown in immediate children of template tags
190+
189191
const disallowed = disallowed_children[parent_tag];
190192

191193
const child = child_loc ? `\`<${child_tag}>\` (${child_loc})` : `\`<${child_tag}>\``;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<template>
2+
<tr>
3+
<td></td>
4+
<td></td>
5+
</tr>
6+
</template>

0 commit comments

Comments
 (0)