Gazebo_simulation-Frontend/node_modules/dom-helpers/esm/closest.js
2020-12-21 10:29:31 -05:00

12 lines
379 B
JavaScript

import matches from './matches';
export default function closest(node, selector, stopAt) {
if (node.closest && !stopAt) node.closest(selector);
var nextNode = node;
do {
if (matches(nextNode, selector)) return nextNode;
nextNode = nextNode.parentElement;
} while (nextNode && nextNode !== stopAt && nextNode.nodeType === document.ELEMENT_NODE);
return null;
}