Skip to content

Use cached select in selectedness setting algorithm#12083

Closed
josepharhar wants to merge 2 commits into
whatwg:mainfrom
josepharhar:selectednesscheck
Closed

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

Conversation

@josepharhar

@josepharhar josepharhar commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

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

@annevk annevk left a comment

Copy link
Copy Markdown
Member

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.

Comment thread source Outdated
Comment thread source Outdated
@josepharhar

Copy link
Copy Markdown
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

zcorpan commented Jan 26, 2026

Copy link
Copy Markdown
Member

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

@josepharhar

Copy link
Copy Markdown
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
Copy Markdown
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

@josepharhar

Copy link
Copy Markdown
Contributor Author

This change is being included in this PR: #12263

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