1
2// Node.prototype.contains
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 }
14 // eslint-disable-next-line no-cond-assign
15 } while (node = node && node.parentNode);
16
17 return false;
18 }
19
20 // IE
21 if ('HTMLElement' in self && 'contains' in HTMLElement.prototype) {
22 try {
23 delete HTMLElement.prototype.contains;
24 // eslint-disable-next-line no-empty
25 } catch (e) {}
26 }
27
28 if ('Node' in self) {
29 Node.prototype.contains = contains;
30 } else {
31 document.contains = Element.prototype.contains = contains;
32 }
33
34}());
35