isDescendantOrSelf.js 320 B

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