From 26d2d5b662c8e42cf2200b16d3fb2b05901160ee Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Wed, 1 Oct 2025 15:38:26 -0700 Subject: [PATCH] Improve optgroup's list of option elements 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 https://github.com/whatwg/html/issues/11730 --- source | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/source b/source index 877761a9424..f6904cb08c8 100644 --- a/source +++ b/source @@ -56161,13 +56161,19 @@ interface HTMLSelectElement : HTMLElement {
-

To get the list of options given a - select element select:

+

The list of options for a + select element select is the result of running descendant + option elements given select.

+
+ +
+

To get the descendant option elements of an HTML element element:

  1. Let options be « ».

  2. -
  3. Let node be the first child of select in tree +

  4. Let node be the first child of element in tree order.

  5. @@ -56188,14 +56194,14 @@ interface HTMLSelectElement : HTMLElement {
  6. node is an option element;

  7. node is an optgroup element and node has an - ancestor optgroup in between itself and select,

  8. - + ancestor optgroup in between itself and + element,

    -

    then set node to the next descendant of select in +

    then set node to the next descendant of element in tree order, excluding node's descendants, if any such node exists; otherwise null.

    -

    Otherwise, set node to the next descendant of select in +

    Otherwise, set node to the next descendant of element in tree order, if any such node exists; otherwise null.

@@ -56825,12 +56831,13 @@ interface HTMLOptGroupElement : HTMLElement {
Uses HTMLOptGroupElement.
-

The optgroup element represents a group of option - elements with a common label.

+

The optgroup element represents a group of option elements with a common label.

-

The element's group of option elements consists of the option - elements that are children of the optgroup element.

+

An optgroup's group of option elements, given an + optgroup element optgroup, is the result of running descendant + option elements given optgroup.

@@ -56843,8 +56850,8 @@ interface HTMLOptGroupElement : HTMLElement {

The disabled attribute is a boolean - attribute and can be used to disable a group - of option elements together.

+ attribute and can be used to disable an + optgroup's group of option elements together.

The label attribute must be specified if the optgroup has no child legend