From 86eae7e77da3a11d6e627a70944483eb095830e6 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Fri, 5 Jan 2024 08:34:25 +0000 Subject: [PATCH] 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 <5968653+dummdidumm@users.noreply.github.com> --- .changeset/good-cars-visit.md | 5 +++++ .../svelte/src/compiler/phases/1-parse/utils/html.js | 11 ++--------- 2 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 .changeset/good-cars-visit.md diff --git a/.changeset/good-cars-visit.md b/.changeset/good-cars-visit.md new file mode 100644 index 0000000000..38e71d6633 --- /dev/null +++ b/.changeset/good-cars-visit.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: allow input elements within button elements diff --git a/packages/svelte/src/compiler/phases/1-parse/utils/html.js b/packages/svelte/src/compiler/phases/1-parse/utils/html.js index bb45f9d6db..309569f4b7 100644 --- a/packages/svelte/src/compiler/phases/1-parse/utils/html.js +++ b/packages/svelte/src/compiler/phases/1-parse/utils/html.js @@ -121,15 +121,8 @@ function validate_code(code) { // based on http://developers.whatwg.org/syntax.html#syntax-tag-omission -const interactive_elements = new Set([ - 'a', - 'button', - 'iframe', - 'embed', - 'input', - 'select', - 'textarea' -]); +// while `input` is also an interactive element, it is never moved by the browser, so we don't need to check for it +const interactive_elements = new Set(['a', 'button', 'iframe', 'embed', 'select', 'textarea']); /** @type {Record>} */ const disallowed_contents = {