select-clear-reappend.tentative.html (926B)
1 <!DOCTYPE html> 2 <link rel=author href="mailto:jarhar@chromium.org"> 3 <link rel=help href="https://github.com/whatwg/html/issues/11825"> 4 <link rel=help href="https://issues.chromium.org/issues/444330901"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <select> 9 <option>one</option> 10 <option selected>two</option> 11 <option>three</option> 12 </select> 13 14 <script> 15 test(() => { 16 const select = document.querySelector('select'); 17 assert_equals(select.value, 'two', 18 'two should be selected at the start of the test.'); 19 20 const options = document.querySelectorAll('option'); 21 select.innerHTML = ''; 22 options.forEach(option => { 23 select.appendChild(option); 24 }); 25 26 assert_equals(select.value, 'two', 27 'two should still be selected after clearing and re-appending.'); 28 }, 'select.value should stay the same after clearing and re-appending options.'); 29 </script>