Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
21 lines
467 B
Plaintext
21 lines
467 B
Plaintext
/**
|
|
* Recursively traverse up the tree to check whether the provided child node
|
|
* is the parent or a descendant of it.
|
|
*
|
|
* @param parent - Element to find
|
|
* @param child - Element to test against parent
|
|
*/
|
|
const isNodeOrChild = (parent, child) => {
|
|
if (!child) {
|
|
return false;
|
|
}
|
|
else if (parent === child) {
|
|
return true;
|
|
}
|
|
else {
|
|
return isNodeOrChild(parent, child.parentElement);
|
|
}
|
|
};
|
|
|
|
export { isNodeOrChild };
|