hugo-theme-zzo/assets/js/helper/closest.js

12 lines
354 B
JavaScript
Raw Normal View History

var closest = function(node, selector) {
return (node.closest || function (_selector) {
do {
if ((node.matches || node.msMatchesSelector).call(node, _selector)) {
return node;
}
node = node.parentElement || node.parentNode;
} while (node !== null && node.nodeType === 1);
return null;
}).call(node, selector);
}