Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selectmenu: Allow nested slotting for options #39204

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/openui/open-ui/issues/565">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<div id=container>
<template shadowrootmode=open>
<selectmenu>
<option>inner option</option>
<slot></slot>
</selectmenu>
</template>
<option>outer option</option>
</div>

<script>
test(() => {
const selectmenu = container.shadowRoot.querySelector('selectmenu');
const slot = container.shadowRoot.querySelector('slot');

selectmenu.value = 'outer option';
assert_equals(selectmenu.value, 'outer option',
'The slotted in option should be selectable.');

slot.remove();
assert_equals(selectmenu.value, 'inner option',
'Removing the slot should remove the slotted option.');

selectmenu.appendChild(document.createElement('slot'));
selectmenu.value = 'outer option';
assert_equals(selectmenu.value, 'outer option',
'Dynamically adding a slot back in should make the slotted option selectable.');

const newOption = document.createElement('option');
newOption.textContent = 'new option';
container.appendChild(newOption);
selectmenu.value = 'new option';
assert_equals(selectmenu.value, 'new option',
'Dynamically added slotted options should be selectable.');
}, 'Slotted options should be selectable.');
</script>