Closed Bug 2068632 Opened 3 days ago Closed 1 day ago

Non-parser created select element might not reflect selected option in .selectedOptions

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

RESOLVED FIXED
157 Branch
Tracking Status
firefox157 --- fixed

People

(Reporter: emilio, Assigned: keithamus)

Details

Attachments

(2 files)

Attached file Test-case.

Sorry for the claude test-case.

Anyway, this seems to be because a non-parser-inserted select never sets mDefaultSelectionSet. Haven't bisected yet:

https://searchfox.org/firefox-main/rev/8a99ef927ea16827f2089e2bdf6a1188ddf645e7/dom/html/HTMLSelectElement.cpp#1476,1484

Assignee: nobody → mozilla
Severity: -- → S3

Bug 2038588, replaced TrySelectSomething, so that option selectedness is only
dirty via OnSelectionChanged. OnSelectionChanged returns early unless
mDefaultSelectionSet is set, and only DoneAddingChildren sets it.
This means it never runs for a select built by script. Removing the last
unselected option from such a combobox, or resetting its form, re-selects the
first enabled option but leaves selectedOptions stale.

This change moves to initialise mIsDoneAddingChildren in the constructor. It's
already set when the select is not parser-created. The result is that the early
return is skipped, allowing the selected option list to become dirty.

Status: NEW → RESOLVED
Closed: 1 day ago
Resolution: --- → FIXED
Target Milestone: --- → 157 Branch

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/62446 for changes under testing/web-platform/tests

Upstream PR merged by moz-wptsync-bot

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: