Skip to content

Commit

Permalink
fix(core): fix element child detection
Browse files Browse the repository at this point in the history
fixes #7636
  • Loading branch information
nolimits4web committed Jul 24, 2024
1 parent 845a206 commit 7ec975c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/shared/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,22 @@ function findElementsInElements(elements = [], selector = '') {
}
function elementChildren(element, selector = '') {
const children = [...element.children];
if(element instanceof HTMLSlotElement) {
children.push(...element.assignedElements())
if (element instanceof HTMLSlotElement) {
children.push(...element.assignedElements());
}

if(!selector) {
if (!selector) {
return children;
}
return children.filter((el) => el.matches(selector));
}
function elementIsChildOf(el, parent) {
const children = elementChildren(parent);
return children.includes(el);
const isChild = parent.contains(el);
if (!isChild && parent instanceof HTMLSlotElement) {
const children = [...element.assignedElements()];
return children.includes(el);
}
return isChild;
}
function showWarning(text) {
try {
Expand Down

0 comments on commit 7ec975c

Please sign in to comment.