Skip to content

Commit 134fcad

Browse files
committed
chore: remove form from interactive elements and add specific check
1 parent 776e837 commit 134fcad

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/svelte/src/compiler/phases/2-analyze/validation.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,17 @@ const validation = {
568568
}
569569
}
570570

571+
// can't add form to interactive elements because those are also used by the parser
572+
// to check for the last auto-closing parent.
573+
if (node.name === 'form') {
574+
const path = context.path;
575+
for (let parent of path) {
576+
if (parent.type === 'RegularElement' && parent.name === 'form') {
577+
e.node_invalid_placement(node, `<${node.name}>`, parent.name);
578+
}
579+
}
580+
}
581+
571582
if (interactive_elements.has(node.name)) {
572583
const path = context.path;
573584
for (let parent of path) {

packages/svelte/src/constants.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ export const interactive_elements = new Set([
118118
'iframe',
119119
'embed',
120120
'select',
121-
'textarea',
122-
'form'
121+
'textarea'
123122
]);
124123

125124
export const disallowed_paragraph_contents = [

0 commit comments

Comments
 (0)