fix: validate form inside a form (#11947)

* fix: validate form inside a form

* chore: remove form from interactive elements and add specific check
pull/11966/head
Paolo Ricciuti 4 months ago committed by GitHub
parent 48fa6587c9
commit 57ca37d6a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: validate form inside a form

@ -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) {

@ -0,0 +1,14 @@
[
{
"code": "node_invalid_placement",
"message": "<form> is invalid inside <form>",
"start": {
"line": 4,
"column": 3
},
"end": {
"line": 6,
"column": 10
}
}
]

@ -0,0 +1,9 @@
<div>
<form>
<div>
<form>
<input />
</form>
</div>
</form>
</div>
Loading…
Cancel
Save