Bug
1646907 [wpt PR 24247] - SELECT element: Fix a regression on adding multiple selected OPTIONs to a single-selection SELECT, a=testonly
Automatic update from web-platform-tests
SELECT element: Fix a regression on adding multiple selected OPTIONs to a single-selection SELECT
This CL fixes a regression caused by crrev.com/745230.
Bug details:
Suppose that |select.innerHTML = '<option selected>Option1' +
'<option selected>Option2'| runs.
Before crrev.com/745230,
1. Option1 is appended to the SELECT.
2. HTMLOptionElement::InsertedInto() and |HTMLSelectElement::
OptionInserted()| are called for Option1.
3. SelectOption(Option1) is called.
4. DeselectItemsWithoutValidation(Option1) is called
5. Option2 is appended to the SELECT.
6. HTMLOptionElement::InsertedInto() and |HTMLSelectElement::
OptionInserted()| are called for Option2.
7. SelectOption(Option2) is called.
8. DeselectItemsWithoutValidation(Option2) is called. Option1's
selected state is cleared.
Since crrev.com/745230,
1. Option1 is appended to the SELECT.
2. Option2 is appended to the SELECT.
3. HTMLSelectElement::ChildrenChanged() and |HTMLSelectElement::
OptionInserted()| are called for Option1.
4. SelectOption(Option1) is called.
5. DeselectItemsWithoutValidation(Option1) is called. Option2's
selected state is cleared.
6. HTMLSelectElement::ChildrenChanged() and |HTMLSelectElement::
OptionInserted()| are called for Option2.
7. SelectOption(Option2) is NOT called because Option2's selected
state was cleared.
Fix:
DeselectItemsWithoutValidation() should not update 'selected' state of
OPTIONs for which OptionInserted() is not called yet. This CL adds a
boolean flag to HTMLOptionElement, it represents whether
OptionInserted() is called or not, and DeselectItemsWithoutValidation()
checks the flag before updating 'selected' state.
Bug:
1095725
Change-Id: If19b28c3edb877549ca498b661647466d03e6d1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/
2253260
Commit-Queue: Kent Tamura <tkent@chromium.org>
Auto-Submit: Kent Tamura <tkent@chromium.org>
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780174}
--
wpt-commits:
e75a8342e588e36a6ab387846a50d077621143b4
wpt-pr: 24247