RESOLVED FIXED 290396
Form controls inside a declarative shadow DOM erroneously get associated with form element in an outer tree
https://bugs.webkit.org/show_bug.cgi?id=290396
Summary Form controls inside a declarative shadow DOM erroneously get associated with...
Konnor Rogers
Reported 2025-03-25 10:05:46 PDT
## Explanation In Desktop Safari 17.5 and 18.3.1 and iOS Safari 18.3.2 (only tested versions so far) a form control rendered inside a declarative shadow DOM leak into the host element's form. This does not happen in Firefox 136 or Chrome 134. Essentially when you have the following: <form> <x-element> <template shadowrootmode="open"> <input name="foo" value="bar"> </template> </x-element> </form> the FormData you will get the following: formData.getAll("foo") // => ["bar"] only in Safari. In Firefox and Chrome you will get an empty array. In addition, doing `form.elements` returns form controls from the shadow dom in Safari. This does not happen when the shadow dom is client side rendered *only* when its rendered via Declarative Shadow DOM. This feels like unintended and unexpected behavior. https://codepen.io/paramagicdev/pen/gbOjxJy ^ reproduction
Attachments
Reduction (224 bytes, text/html)
2025-03-25 18:50 PDT, Ryosuke Niwa
no flags
More test cases (758 bytes, text/html)
2025-03-25 19:15 PDT, Ryosuke Niwa
no flags
Ryosuke Niwa
Comment 1 2025-03-25 18:50:50 PDT
Created attachment 474714 [details] Reduction
Ryosuke Niwa
Comment 2 2025-03-25 19:15:39 PDT
Created attachment 474715 [details] More test cases
Ryosuke Niwa
Comment 3 2025-03-25 23:55:58 PDT
Konnor Rogers
Comment 4 2025-03-26 00:32:26 PDT
As an additional note, the same mechanism seems to affect button submissions as well: https://codepen.io/paramagicdev/pen/bNGjmZg buttons clicked inside a declarative shadow dom cause a form in an outer tree to submit.
EWS
Comment 5 2025-03-26 08:20:15 PDT
Committed 292703@main (e657338dfd41): <https://commits.webkit.org/292703@main> Reviewed commits have been landed. Closing PR #43034 and removing active labels.
Radar WebKit Bug Importer
Comment 6 2025-03-26 08:21:15 PDT
Note You need to log in before you can comment on or make changes to this bug.