isDescendantOrSelf.js 287 B

123456789101112
  1. function isDescendantOrSelf(potentialDescendant, potentialAncestor) {
  2. let el = potentialDescendant;
  3. do {
  4. if (el === potentialAncestor) {
  5. return true;
  6. }
  7. el = el.parentElement;
  8. }while (el)
  9. return false;
  10. }
  11. export { isDescendantOrSelf };