Skip to content

Commit

Permalink
Remove author-provided <datalist> from <select>
Browse files Browse the repository at this point in the history
The author-provided datalist imposes a lot of complexity, and now that
we aren't requiring it for HTML parser changes, it doesn't provide any
additional capabilities.

This patch also makes the UA popover actually have the popover attribute
and makes it a <div> instead of a <datalist>.

No code or concepts have "datalist" in them anymore except
::select-fallback-datalist because that is likely to get a different
standards-approved name soon.

This was discussed here: openui/open-ui#1082

This patch also moves a bunch of tests from external/wpt to wpt_internal
because we aren't allowed to use test_driver in reftests in
external/wpt, and I was using datalist.showPicker() in a bunch of
reftests which we can't do anymore because the popover is now a
pseudo-element which can only be opened via select.showPicker() which
requires user activation, and in order to get user activation, we have
to run test_driver.bless().

Change-Id: Ib8230bc5eec214f09147ae806490df729f1e4412
  • Loading branch information
josepharhar authored and chromium-wpt-export-bot committed Aug 28, 2024
1 parent 2a7b7ed commit 32b248f
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 434 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

<select>
<option class=one>one</option>
<datalist id=datalist1>
<div id=div1>
<option class=two>two</option>
<div id=div1>
<div>
<option class=three>three</option>
</div>
<option class=four>four</option>
</datalist>
<datalist>
</div>
<div>
<option class=five>five</option>
</datalist>
</div>
<div id=div2>
<option class=six>six</option>
</div>
Expand All @@ -25,14 +25,13 @@
const select = document.querySelector('select');

function runTest() {
const datalist = document.getElementById('datalist1');
const wrapperDiv = document.getElementById('div1');
const firstOption = select.querySelector('option.one');
const secondOption = select.querySelector('option.two');
const thirdOption = select.querySelector('option.three');
const fourthOption = select.querySelector('option.four');
const fifthOption = select.querySelector('option.five');
const sixthOption = select.querySelector('option.six');
const datalistChildDiv = document.getElementById('div1');
const selectChildDiv = document.getElementById('div2');

assert_equals(select.length, 6, 'select.length');
Expand All @@ -57,7 +56,7 @@
assert_equals(select.options[3], fifthOption, 'select.options[1] after removing an option');
assert_equals(select.options[4], sixthOption, 'select.options[1] after removing an option');

datalist.appendChild(fourthOption);
wrapperDiv.appendChild(fourthOption);
assert_equals(select.length, 6, 'select.length after re-adding an option');
assert_equals(select.options.length, 6, 'select.options.length after re-adding an option');
assert_equals(select.options[0], firstOption, 'select.options[0] after re-adding an option');
Expand All @@ -78,22 +77,22 @@
assert_equals(select.options[5], fourthOption, 'select.options[5] after moving option to child div');

// reset back to normal for the next test
datalist.appendChild(fourthOption);
wrapperDiv.appendChild(fourthOption);
select.value = 'one';
}

test(() => {
runTest();
}, 'Option elements should work if they are a descendant of a selects datalist.');
}, 'Option elements should work if they are a descendant of a selects wrapper div.');

test(() => {
select.setAttribute('multiple', '');
runTest();
}, 'Options in datalist should still work when the multiple attribute is added.');
}, 'Options in wrapper div should still work when the multiple attribute is added.');

test(() => {
select.innerHTML = select.innerHTML;
select.value = 'one';
runTest();
}, 'Options in datalist in multiple should work after re-parsing and re-attaching.');
}, 'Options in wrapper div in multiple should work after re-parsing and re-attaching.');
</script>

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 32b248f

Please sign in to comment.