18
|
1 |
|
|
2 |
// Node.prototype.contains |
9
|
3 |
(function() { |
|
4 |
|
|
5 |
function contains(node) { |
|
6 |
if (!(0 in arguments)) { |
|
7 |
throw new TypeError('1 argument is required'); |
|
8 |
} |
|
9 |
|
|
10 |
do { |
|
11 |
if (this === node) { |
|
12 |
return true; |
|
13 |
} |
18
|
14 |
// eslint-disable-next-line no-cond-assign |
9
|
15 |
} while (node = node && node.parentNode); |
|
16 |
|
|
17 |
return false; |
|
18 |
} |
|
19 |
|
|
20 |
// IE |
18
|
21 |
if ('HTMLElement' in self && 'contains' in HTMLElement.prototype) { |
9
|
22 |
try { |
|
23 |
delete HTMLElement.prototype.contains; |
18
|
24 |
// eslint-disable-next-line no-empty |
9
|
25 |
} catch (e) {} |
|
26 |
} |
|
27 |
|
18
|
28 |
if ('Node' in self) { |
9
|
29 |
Node.prototype.contains = contains; |
|
30 |
} else { |
|
31 |
document.contains = Element.prototype.contains = contains; |
|
32 |
} |
|
33 |
|
|
34 |
}()); |