Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/forms/the-select-element/select-clear-reappend.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<select>
<option>one</option>
<option selected>two</option>
<option>three</option>
</select>
<script>
test(() => {
const select = document.querySelector('select');
assert_equals(select.value, 'two',
'two should be selected at the start of the test.');
const options = document.querySelectorAll('option');
select.innerHTML = '';
options.forEach(option => {
select.appendChild(option);
});
assert_equals(select.value, 'two',
'two should still be selected after clearing and re-appending.');
}, 'select.value should stay the same after clearing and re-appending options.');
</script>