Skip to content

Conversation

josepharhar
Copy link
Contributor

@josepharhar josepharhar commented Oct 1, 2025

Now that optgroups need to look through their descendants to find option elements, the definition of an optgroup's options just being its children option elements is no longer correct. This PR changes that definition to use the same algorithm that the select element uses to collect its option elements, which incorporates nesting options inside other options, optgroups, and selects.

Fixes #11730

(See WHATWG Working Mode: Changes for more details.)


/form-elements.html ( diff )

Now that optgroups need to look through their descendants to find
option elements, the definition of an optgroup's options just being its
children option elements is no longer correct. This PR changes that
definition to use the same algorithm that the select element uses to
collect its option elements, which incorporates nesting options inside
other options, optgroups, and selects.

Fixes whatwg#11730
Comment on lines 56196 to +56198
<li><p><var>node</var> is an <code>optgroup</code> element and <var>node</var> has an
<span>ancestor</span> <code>optgroup</code> in between itself and <var>select</var>,</p></li>
</ul>
<span>ancestor</span> <code>optgroup</code> in between itself and
<var>element</var>,</p></li> </ul>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running these steps for an optgroup element, the second check should be skipped, right? Otherwise options in optgroup in optgroup will be returned by the outer optgroup's "descendant option elements".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

optgroup element text is incorrect
2 participants