amis-rpc-design/node_modules/rc-util/es/Dom/contains.js

20 lines
345 B
JavaScript
Raw Normal View History

2023-10-07 19:42:30 +08:00
export default function contains(root, n) {
if (!root) {
return false;
}
// Use native if support
if (root.contains) {
return root.contains(n);
}
// `document.contains` not support with IE11
var node = n;
while (node) {
if (node === root) {
return true;
}
node = node.parentNode;
}
return false;
}