Skip to content

Comments

Use cached select in selectedness setting algorithm#12083

Open
josepharhar wants to merge 2 commits intowhatwg:mainfrom
josepharhar:selectednesscheck
Open

Use cached select in selectedness setting algorithm#12083
josepharhar wants to merge 2 commits intowhatwg:mainfrom
josepharhar:selectednesscheck

Conversation

@josepharhar
Copy link
Contributor

@josepharhar josepharhar commented Jan 13, 2026

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: #11825

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


/form-elements.html ( diff )

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: whatwg#11825
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

How does this PR relate to #11890? It's getting quite confusing.

@josepharhar
Copy link
Contributor Author

How does this PR relate to #11890? It's getting quite confusing.

I listed some different ways we can proceed here: #11890 (comment)

@zcorpan
Copy link
Member

zcorpan commented Jan 26, 2026

Is this sufficiently tested by web-platform-tests/wpt#55647 ?

@josepharhar
Copy link
Contributor Author

I removed the code which does this in chromium in order to find tests which would fail, and I found that html/semantics/forms/the-select-element/inserted-or-removed.html would fail without this logic, specifically with this failure:

This is a testharness.js-based test.
[FAIL] The last selected OPTION should win; Inserted by DOM API
  assert_equals: expected "Second" but got "First"
Harness: the test ran to completion.

I'll add this test to the OP

@josepharhar
Copy link
Contributor Author

We also have an internal test which would fail without this, which I could move to WPT: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/fast/forms/select/multiple-selected-options-innerHTML.html

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.

3 participants