From 1998394054f4ed6cace01330afce565f58f92d2b Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Tue, 13 Jan 2026 11:24:20 -0800 Subject: [PATCH 1/2] Use cached select in selectedness setting algorithm In order to make the selectedness setting algorithm match implementations, this PR makes the selectedness setting algorithm avoid changing the selectedness of option elements which haven't ran their insertion steps yet by checking whether the options have their cached nearest ancestor select element assigned yet or not. This was discussed here: https://github.com/whatwg/html/issues/11825 --- source | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/source b/source index c674496762c..fa88996a1be 100644 --- a/source +++ b/source @@ -56317,14 +56317,37 @@ interface HTMLSelectElement : HTMLElement { tree order that is not disabled, if any, to true, and return.

-
  • If element's multiple attribute is - absent, and two or more option elements in element's list of options have their selectedness set to true, then set the selectedness of all but the last option - element with its selectedness set to true in - the list of options in tree order - to false.

  • +
  • +

    If element's multiple attribute is + absent:

    + +
      +
    1. Let lastSelectedOption be null.

    2. + +
    3. +

      For each option in element's list of options in reverse order:

      + +
        +
      1. +

        If option's selectedness + is true:

        + +
          +
        1. If option's cached nearest ancestor select + element is null, then continue.

        2. + +
        3. If lastSelectedOption is null, then set lastSelectedOption to + option and continue.

        4. + +
        5. Set option's selectedness to false.

        6. +
        +
      2. +
      +
    4. +
    +
  • From af049b78ccd8055de18608c28c54376ee9931712 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Thu, 15 Jan 2026 12:57:19 -0800 Subject: [PATCH 2/2] readability improvements --- source | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/source b/source index fa88996a1be..4c67344ea69 100644 --- a/source +++ b/source @@ -56318,32 +56318,29 @@ interface HTMLSelectElement : HTMLElement { if any, to true, and return.

  • -

    If element's multiple attribute is - absent:

    +

    If element has the multiple attribute, + then return.

    -
      -
    1. Let lastSelectedOption be null.

    2. +
    3. Let lastSeen be false.

    4. + +
    5. +

      For each option in element's list of options in reverse order:

      +
      1. -

        For each option in element's list of options in reverse order:

        +

        If option's selectedness + is true:

          -
        1. -

          If option's selectedness - is true:

          +
        2. If option's cached nearest ancestor select + element is null, then continue.

        3. -
            -
          1. If option's cached nearest ancestor select - element is null, then continue.

          2. - -
          3. If lastSelectedOption is null, then set lastSelectedOption to - option and continue.

          4. +
          5. If lastSeen is false, then set lastSeen to true and + continue.

          6. -
          7. Set option's selectedness to false.

          8. -
          - +
        4. Set option's selectedness to false.