UNPKG

dom-tools

Version:

A tiny collection of DOM helpers for IE8+.

23 lines (18 loc) 685 B
var canUseDOM = require('./canUseDOM'); // react-bootstrap/dom-helpers 2.4.0 query/contains.js var contains = (function(){ var root = canUseDOM && document.documentElement; return (root && root.contains) ? function(context, node){ return context.contains(node); } : (root && root.compareDocumentPosition) ? function(context, node){ return context === node || !!(context.compareDocumentPosition(node) & 16); } : function(context, node){ if (node) do { if (node === context) return true; } while ((node = node.parentNode)); return false; } })(); module.exports = contains;