Skip to content

Commit 8da3908

Browse files
committed
submit-with-selected-menu-item can use a form attribute instead
* For dropdowns that are within `form` elements, we need to be able to specify a `form` attribute that can act as the "form owner", since nested `form` elements are not spec-compliant * This mirrors the `form` attribute for standard inputs and buttons * See: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form * If no `form` attribute is provided, the element continues operating from the assumption that there is a `form` inside the custom element
1 parent 6aed430 commit 8da3908

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/elements/submit-with-selected-menu-item.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ class SubmitWithSelectedMenuItemElement extends HTMLElement {
2020
}
2121

2222
get form() {
23-
return this.querySelector(`:scope form`)
23+
if(this.hasAttribute(`form`)) {
24+
return document.getElementById(this.getAttribute(`form`))
25+
} else {
26+
return this.querySelector(`:scope form`)
27+
}
2428
}
2529
}
2630

0 commit comments

Comments
 (0)