From 56700e588e63da8a07ec25f096910cbef64e7dd1 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Fri, 10 Jan 2025 12:07:24 -0500 Subject: [PATCH] fix(core): add check for HTMLSlotElement support (#7840) * Add check for slot support * getWindow --------- Co-authored-by: Vladimir Kharlampidi --- src/shared/utils.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shared/utils.mjs b/src/shared/utils.mjs index c69ec5750..bc0b5b079 100644 --- a/src/shared/utils.mjs +++ b/src/shared/utils.mjs @@ -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()); } @@ -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) {