Skip to content

Commit 86eae7e

Browse files
trueadmdummdidumm
andauthored
fix: loosen input in button error (#10083)
The validation exists to error on html that would result in the browser repairing it, causing hydration errors. input is never moved, so we can remove it from the array --------- Co-authored-by: Simon H <[email protected]>
1 parent 94aab90 commit 86eae7e

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

.changeset/good-cars-visit.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: allow input elements within button elements

packages/svelte/src/compiler/phases/1-parse/utils/html.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,8 @@ function validate_code(code) {
121121

122122
// based on http://developers.whatwg.org/syntax.html#syntax-tag-omission
123123

124-
const interactive_elements = new Set([
125-
'a',
126-
'button',
127-
'iframe',
128-
'embed',
129-
'input',
130-
'select',
131-
'textarea'
132-
]);
124+
// while `input` is also an interactive element, it is never moved by the browser, so we don't need to check for it
125+
const interactive_elements = new Set(['a', 'button', 'iframe', 'embed', 'select', 'textarea']);
133126

134127
/** @type {Record<string, Set<string>>} */
135128
const disallowed_contents = {

0 commit comments

Comments
 (0)