Skip to content

Commit

Permalink
chore: remove form from interactive elements and add specific check
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloricciuti committed Jun 6, 2024
1 parent 776e837 commit 134fcad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 11 additions & 0 deletions packages/svelte/src/compiler/phases/2-analyze/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions packages/svelte/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ export const interactive_elements = new Set([
'iframe',
'embed',
'select',
'textarea',
'form'
'textarea'
]);

export const disallowed_paragraph_contents = [
Expand Down

0 comments on commit 134fcad

Please sign in to comment.