33 lines
921 B
JavaScript
33 lines
921 B
JavaScript
|
|
"use strict";
|
||
|
|
|
||
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||
|
|
|
||
|
|
exports.__esModule = true;
|
||
|
|
exports.default = void 0;
|
||
|
|
|
||
|
|
var _inDOM = _interopRequireDefault(require("../util/inDOM"));
|
||
|
|
|
||
|
|
var _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 _inDOM.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;
|
||
|
|
}();
|
||
|
|
|
||
|
|
exports.default = _default;
|
||
|
|
|
||
|
|
function fallback(context, node) {
|
||
|
|
if (node) do {
|
||
|
|
if (node === context) return true;
|
||
|
|
} while (node = node.parentNode);
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
module.exports = exports["default"];
|