Skip to content
Merged
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
33 changes: 33 additions & 0 deletions dom/nodes/moveBefore/tentative/slotchange-events.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,37 @@
await slotChangePromise;
}
}, "Moving a slottable into and out out of a custom element fires 'slotchange' event");

promise_test(async t => {
const customElement = document.body.appendChild(document.createElement('custom-element'));
const slot = customElement.shadowRoot.children[0];
t.add_cleanup(() => customElement.remove());

const p = document.createElement('p');
p.slot = 'content';
p.textContent = 'The content';
customElement.appendChild(p);

// See the above tests that do the same thing, for implementations that do not fire `slotchange`
// at this phase.
await new Promise(resolve => t.step_timeout(() => resolve()));

assert_array_equals(slot.assignedNodes(), [p]);
document.body.moveBefore(slot, null);

await new Promise((resolve, reject) => {
slot.addEventListener('slotchange', e => resolve(), {once: true});
t.step_timeout(() => reject('Timeout; slotchange was not fired2'), 1500);
});

assert_array_equals(slot.assignedNodes(), []);
customElement.shadowRoot.moveBefore(slot, null);

await new Promise((resolve, reject) => {
slot.addEventListener('slotchange', e => resolve(), {once: true});
t.step_timeout(() => reject('Timeout; slotchange was not fired3'), 1500);
});

assert_array_equals(slot.assignedNodes(), [p]);
}, "Moving a slot runs the assign slottables algorithm");
</script>