Initial commit
This commit is contained in:
34
node_modules/dom-helpers/query/contains.js
generated
vendored
Normal file
34
node_modules/dom-helpers/query/contains.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _inDOM = require('../util/inDOM');
|
||||
|
||||
var _inDOM2 = _interopRequireDefault(_inDOM);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.default = function () {
|
||||
// HTML DOM and SVG DOM may have different support levels,
|
||||
// so we need to check on context instead of a document root element.
|
||||
return _inDOM2.default ? function (context, node) {
|
||||
if (context.contains) {
|
||||
return context.contains(node);
|
||||
} else if (context.compareDocumentPosition) {
|
||||
return context === node || !!(context.compareDocumentPosition(node) & 16);
|
||||
} else {
|
||||
return fallback(context, node);
|
||||
}
|
||||
} : fallback;
|
||||
}();
|
||||
|
||||
function fallback(context, node) {
|
||||
if (node) do {
|
||||
if (node === context) return true;
|
||||
} while (node = node.parentNode);
|
||||
|
||||
return false;
|
||||
}
|
||||
module.exports = exports['default'];
|
||||
Reference in New Issue
Block a user