12 lines
178 B
JavaScript
12 lines
178 B
JavaScript
|
export default function contains(root, n) {
|
||
|
let node = n;
|
||
|
while (node) {
|
||
|
if (node === root) {
|
||
|
return true;
|
||
|
}
|
||
|
node = node.parentNode;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|