13 lines
287 B
JavaScript
13 lines
287 B
JavaScript
function isDescendantOrSelf(potentialDescendant, potentialAncestor) {
|
|
let el = potentialDescendant;
|
|
do {
|
|
if (el === potentialAncestor) {
|
|
return true;
|
|
}
|
|
el = el.parentElement;
|
|
}while (el)
|
|
return false;
|
|
}
|
|
|
|
export { isDescendantOrSelf };
|