Skip to content

Comments

Don't select options when all children are removed#55647

Merged
chromium-wpt-export-bot merged 1 commit intomasterfrom
chromium-export-cl-7058561
Oct 24, 2025
Merged

Don't select options when all children are removed#55647
chromium-wpt-export-bot merged 1 commit intomasterfrom
chromium-export-cl-7058561

Conversation

@chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Oct 24, 2025

This patch fixes a regression caused when moving the calls to
HTMLSelectElement::OptionInserted/OptionRemoved from
HTMLSelectElement::ChildrenChanged to
HTMLOptionElement::InsertedInto/RemovedFrom.

In the pre-regression code path when all options are removed from the
select at once via select.innerHTML = '' for example, the options
selectedness would not be modified because the ResetToDefaultSelection
would only be called once after all the options are removed.

In the post-regression code path, ResetToDefaultSelection is called in
between each option being removed in HTMLOptionElement::RemovedFrom,
which results in every option becoming selected before they are
eventually removed.

This patch replicates the pre-regression behavior by moving calls to
OptionRemoved from HTMLOptionElement::RemovedFrom to
HTMLSelectElement::ChildrenChanged in the case that the option element
is a direct child of the select element.

A better fix might be to always set selectedness to false when an option
is removed from a select element, but that might have other unintended
consequences.

Spec issue: whatwg/html#11825

Fixed: 444330901
Change-Id: I10b7a501993229cccff1e7aa36a7eb306f2da0d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7058561
Reviewed-by: David Baron <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1535201}

This patch fixes a regression caused when moving the calls to
HTMLSelectElement::OptionInserted/OptionRemoved from
HTMLSelectElement::ChildrenChanged to
HTMLOptionElement::InsertedInto/RemovedFrom.

In the pre-regression code path when all options are removed from the
select at once via select.innerHTML = '' for example, the options
selectedness would not be modified because the ResetToDefaultSelection
would only be called once after all the options are removed.

In the post-regression code path, ResetToDefaultSelection is called in
between each option being removed in HTMLOptionElement::RemovedFrom,
which results in every option becoming selected before they are
eventually removed.

This patch replicates the pre-regression behavior by moving calls to
OptionRemoved from HTMLOptionElement::RemovedFrom to
HTMLSelectElement::ChildrenChanged in the case that the option element
is a direct child of the select element.

A better fix might be to always set selectedness to false when an option
is removed from a select element, but that might have other unintended
consequences.

Spec issue: whatwg/html#11825

Fixed: 444330901
Change-Id: I10b7a501993229cccff1e7aa36a7eb306f2da0d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7058561
Reviewed-by: David Baron <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1535201}
Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

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

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot merged commit 05fa548 into master Oct 24, 2025
18 checks passed
@chromium-wpt-export-bot chromium-wpt-export-bot deleted the chromium-export-cl-7058561 branch October 24, 2025 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants