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