Skip to content

Select::options and optgroup bugfix#470

Open
g105b wants to merge 5 commits intomasterfrom
351
Open

Select::options and optgroup bugfix#470
g105b wants to merge 5 commits intomasterfrom
351

Conversation

@g105b
Copy link
Member

@g105b g105b commented Mar 23, 2026

I found a real inconsistency: $select->options already walks descendant <option> elements, but $select->elements still returns only direct children, and length is derived from elements.

That means <optgroup> breaks the select’s option model in part of the API. I'm fixing that at the shared collection layer instead of patching one property in isolation.

The bug is fixed in HTMLElement. <select> now builds a single shared HTMLOptionsCollection from descendant option elements in tree order, so options, elements, and length stay consistent when options are nested inside <optgroup>.

I also tightened the regression test in HTMLSelectElementTest so it assetrs both $select->options ordering and $select->length across two optgroups.

@g105b g105b linked an issue Mar 26, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test HTMLSelectElement::options when using optgroup

1 participant