Skip to content

Commit

Permalink
feat: allow every children in template tags (#15007)
Browse files Browse the repository at this point in the history
* feat: allow every children in `template` tags

* Update .changeset/dry-mails-return.md

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
  • Loading branch information
paoloricciuti and Rich-Harris authored Jan 14, 2025
1 parent a1698c6 commit dfa97a5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-mails-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': minor
---

feat: allow `<template>` elements to contain any child
2 changes: 2 additions & 0 deletions packages/svelte/src/html-tree-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ export function is_tag_valid_with_ancestor(child_tag, ancestors, child_loc, ance
export function is_tag_valid_with_parent(child_tag, parent_tag, child_loc, parent_loc) {
if (child_tag.includes('-') || parent_tag?.includes('-')) return null; // custom elements can be anything

if (parent_tag === 'template') return null; // no errors or warning should be thrown in immediate children of template tags

const disallowed = disallowed_children[parent_tag];

const child = child_loc ? `\`<${child_tag}>\` (${child_loc})` : `\`<${child_tag}>\``;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template>
<tr>
<td></td>
<td></td>
</tr>
</template>

0 comments on commit dfa97a5

Please sign in to comment.