Skip to content

Commit

Permalink
[SelectMenu] Use option.value for selectmenu.value
Browse files Browse the repository at this point in the history
This CL updates the behavior so that option.value attribute is used for
selectmenu.value. When the value attribute is not specified, the option
content will be used instead.

Since after [1], the option parts are sync updated, there is no need
to ensure that the selected option is valid before being used.

[1]: https://chromium-review.googlesource.com/c/chromium/src/+/3285630

Bug: 1121840
Change-Id: I2b828d77fe7306eec22f99938e10666004532524
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3315596
Reviewed-by: Dan Clark <[email protected]>
Reviewed-by: Mason Freed <[email protected]>
Commit-Queue: Ionel Popescu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#948242}
  • Loading branch information
ipopescu93 authored and chromium-wpt-export-bot committed Dec 4, 2021
1 parent bb1a81e commit e9a0e96
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
<option>three</option>
</selectmenu>

<selectmenu id="selectMenu7">
<option id="selectMenu7-option1">one</option>
<option selected value="test">two</option>
<option>three</option>
</selectmenu>

<script>

test(() => {
Expand Down Expand Up @@ -152,4 +158,20 @@
assert_false(newOption.selected);
}, "Test that HTMLOption.selected updates selectmenu.value");

test(() => {
const selectMenu = document.getElementById("selectMenu7");
let selectMenuOption1 = document.getElementById("selectMenu7-option1");

assert_equals(selectMenu.value, "test");
assert_false(selectMenuOption1.selected);
selectMenuOption1.selected = true;
assert_equals(selectMenu.value, "one");
selectMenuOption1.value = "new test";
assert_equals(selectMenu.value, "new test");
selectMenuOption1.removeAttribute("value");
assert_equals(selectMenu.value, "one");
selectMenuOption1.value = "";
assert_equals(selectMenu.value, "");
}, "Test that HTMLOption.value updates selectmenu.value");

</script>

0 comments on commit e9a0e96

Please sign in to comment.