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