Skip to content

Commit

Permalink
fix: hr, script and template as valid select children (#11344)
Browse files Browse the repository at this point in the history
Closes #11342
---------

Co-authored-by: Jeremiasz Major <jrh.mjr@gmail.com>
  • Loading branch information
paoloricciuti and jrmajor committed Apr 27, 2024
1 parent cd79807 commit d3949a6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/cyan-squids-drive.md
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: make hr, script and template valid select children
9 changes: 8 additions & 1 deletion packages/svelte/src/constants.js
Expand Up @@ -158,7 +158,14 @@ export function is_tag_valid_with_parent(tag, parent_tag) {
switch (parent_tag) {
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect
case 'select':
return tag === 'option' || tag === 'optgroup' || tag === '#text';
return (
tag === 'option' ||
tag === 'optgroup' ||
tag === '#text' ||
tag === 'hr' ||
tag === 'script' ||
tag === 'template'
);
case 'optgroup':
return tag === 'option' || tag === '#text';
// Strictly speaking, seeing an <option> doesn't mean we're in a <select>
Expand Down
@@ -0,0 +1 @@
[]
@@ -0,0 +1,12 @@
<script>
</script>

<select>
<option value="0">The</option>
<hr>
<script>
console.log("hei");
</script>
<template>Cool</template>
<option value="1">bug</option>
</select>

0 comments on commit d3949a6

Please sign in to comment.