Skip to content

Don't update selectedcontent in option insertion/removal steps#59528

Merged
chromium-wpt-export-bot merged 1 commit intomasterfrom
chromium-export-cl-7745871
Apr 29, 2026
Merged

Don't update selectedcontent in option insertion/removal steps#59528
chromium-wpt-export-bot merged 1 commit intomasterfrom
chromium-export-cl-7745871

Conversation

@chromium-wpt-export-bot
Copy link
Copy Markdown
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Apr 28, 2026

Modifying the DOM by updating selectedcontent elements during insertion
or removal steps is bad for security reasons. We already removed the
selectedcontent element removal steps which was one way this can happen,
but the option's InsertedInto and RemovedFrom methods may change which
option is selected, which will synchronously update the selectedcontent
element.

This patch fixes this by moving the selectedcontent updating to the
post-insertion steps for insertion, and by using a microtask to update
on removal if needed.

This matches the behavior in the spec PR: whatwg/html#12263

Bug: 458113204
Change-Id: I42bb94c6eace93445cfbc816529e42ca8a561b94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7745871
Reviewed-by: David Baron <dbaron@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1622241}

Modifying the DOM by updating selectedcontent elements during insertion
or removal steps is bad for security reasons. We already removed the
selectedcontent element removal steps which was one way this can happen,
but the option's InsertedInto and RemovedFrom methods may change which
option is selected, which will synchronously update the selectedcontent
element.

This patch fixes this by moving the selectedcontent updating to the
post-insertion steps for insertion, and by using a microtask to update
on removal if needed.

This matches the behavior in the spec PR: whatwg/html#12263

Bug: 458113204
Change-Id: I42bb94c6eace93445cfbc816529e42ca8a561b94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7745871
Reviewed-by: David Baron <dbaron@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1622241}
Copy link
Copy Markdown
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 8116dc1 into master Apr 29, 2026
28 checks passed
@chromium-wpt-export-bot chromium-wpt-export-bot deleted the chromium-export-cl-7745871 branch April 29, 2026 07: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