Skip to content

Conversation

@karlseguin
Copy link
Collaborator

Libdom's formGetCollection doesn't work (like I would expect) for dynamically added elements.

For example, given:

let el = document.createElement('input');
document.getElementsByTagName('form')[0].append(el);

(and assume the page has a form), I'd expect el.form to be equal to the form the input was added to. Instead, it's null. This is a problem given that dom_html_form_element_get_elements uses the element's form attribute to "collect" the elements.

This uses our existing querySelector to find the form elements.

Libdom's formGetCollection doesn't work (like I would expect) for dynamically
added elements.

For example, given:

```
let el = document.createElement('input');
document.getElementsByTagName('form')[0].append(el);
```

(and assume the page has a form), I'd expect `el.form` to be equal to the form
the input was added to. Instead, it's null. This is a problem given that
`dom_html_form_element_get_elements` uses the element's `form` attribute to
"collect" the elements.

This uses our existing querySelector to find the form elements.
@karlseguin karlseguin force-pushed the form_support_dynamic_elements branch from 4ab4cf5 to eadb5b6 Compare June 16, 2025 05:49
@karlseguin karlseguin merged commit 26e8642 into main Jun 17, 2025
11 checks passed
@karlseguin karlseguin deleted the form_support_dynamic_elements branch June 17, 2025 00:07
@github-actions github-actions bot locked and limited conversation to collaborators Jun 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants