Skip to content

Commit

Permalink
fix(core): add check for HTMLSlotElement support (#7840)
Browse files Browse the repository at this point in the history
* Add check for slot support

* getWindow

---------

Co-authored-by: Vladimir Kharlampidi <nolimits4web@gmail.com>
  • Loading branch information
thornbill and nolimits4web authored Jan 10, 2025
1 parent 69113c9 commit 56700e5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/shared/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ function findElementsInElements(elements = [], selector = '') {
return found;
}
function elementChildren(element, selector = '') {
const window = getWindow();
const children = [...element.children];
if (element instanceof HTMLSlotElement) {
if (window.HTMLSlotElement && element instanceof HTMLSlotElement) {
children.push(...element.assignedElements());
}

Expand All @@ -229,8 +230,9 @@ function elementIsChildOfSlot(el, slot) {
}
}
function elementIsChildOf(el, parent) {
const window = getWindow();
let isChild = parent.contains(el);
if (!isChild && parent instanceof HTMLSlotElement) {
if (!isChild && window.HTMLSlotElement && parent instanceof HTMLSlotElement) {
const children = [...parent.assignedElements()];
isChild = children.includes(el);
if (!isChild) {
Expand Down

0 comments on commit 56700e5

Please sign in to comment.