Commit 6b4b5fc
committed
REGRESSION (254522@main): HTMLSelectElement's value setter sets incorrect values if there are grouped options
https://bugs.webkit.org/show_bug.cgi?id=251024
rdar://103520364
Reviewed by Ryosuke Niwa.
While updating `HTMLSelectElement::listItems` to use `WeakPtr`, 254522@main
also modified `HTMLSelectElement::setValue` to use `Vector::findIf` to
obtain the index of the selected option. However, `listItems` includes
`<optgroup>` elements, resulting in the index of the selected option being
offset by the number of `<optgroup>` elements before it. `<optgroup>` elements
should be ignored when determining the index of the selected option.
To fix, restore the range-based for loop that was used prior to 254522@main.
* LayoutTests/fast/forms/select-optgroup-set-value-expected.txt: Added.
* LayoutTests/fast/forms/select-optgroup-set-value.html: Added.
* Source/WebCore/html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::setValue):
Canonical link: https://commits.webkit.org/259249@main1 parent 4006773 commit 6b4b5fc
File tree
3 files changed
+46
-7
lines changed- LayoutTests/fast/forms
- Source/WebCore/html
3 files changed
+46
-7
lines changedLines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
268 | 272 | | |
269 | | - | |
| 273 | + | |
270 | 274 | | |
271 | 275 | | |
272 | 276 | | |
| |||
0 commit comments