UNPKG

@studiometa/js-toolkit

Version:

A set of useful little bits of JavaScript to boost your project! 🚀

16 lines (15 loc) • 440 B
function getAncestorWhere(element, condition) { if (!element) { return null; } const ancestor = element.parentElement; return condition(ancestor) ? ancestor : getAncestorWhere(ancestor, condition); } function getAncestorWhereUntil(element, condition, until) { return getAncestorWhere(element, (el) => condition(el) || until(el)); } export { getAncestorWhere, getAncestorWhereUntil }; //# sourceMappingURL=ancestors.js.map