UNPKG

@mapbox/query-selector-contains-node

Version:

Check whether a node is contained by any other node on the page matching a selector

12 lines (11 loc) 306 B
module.exports = function querySelectorContainsNode(selector, node) { var candidates = document.querySelectorAll(selector); var i; var l = candidates.length; for (i = 0; i < l; i++) { if (candidates[i] === node || candidates[i].contains(node)) { return true; } } return false; };