From 134fcadcf155d68429ed9930ee1e92f2ab9380c3 Mon Sep 17 00:00:00 2001 From: paoloricciuti Date: Fri, 7 Jun 2024 00:41:29 +0200 Subject: [PATCH] chore: remove form from interactive elements and add specific check --- .../src/compiler/phases/2-analyze/validation.js | 11 +++++++++++ packages/svelte/src/constants.js | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/svelte/src/compiler/phases/2-analyze/validation.js b/packages/svelte/src/compiler/phases/2-analyze/validation.js index 51bb4d85fd..e54828375e 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/validation.js +++ b/packages/svelte/src/compiler/phases/2-analyze/validation.js @@ -568,6 +568,17 @@ const validation = { } } + // can't add form to interactive elements because those are also used by the parser + // to check for the last auto-closing parent. + if (node.name === 'form') { + const path = context.path; + for (let parent of path) { + if (parent.type === 'RegularElement' && parent.name === 'form') { + e.node_invalid_placement(node, `<${node.name}>`, parent.name); + } + } + } + if (interactive_elements.has(node.name)) { const path = context.path; for (let parent of path) { diff --git a/packages/svelte/src/constants.js b/packages/svelte/src/constants.js index 9b439a6479..63949f7e99 100644 --- a/packages/svelte/src/constants.js +++ b/packages/svelte/src/constants.js @@ -118,8 +118,7 @@ export const interactive_elements = new Set([ 'iframe', 'embed', 'select', - 'textarea', - 'form' + 'textarea' ]); export const disallowed_paragraph_contents = [