mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-19 17:15:16 +01:00
85c90c4e01
Follow up to [50615]. Props gziolo. Fixes #52854. Built from https://develop.svn.wordpress.org/trunk@50617 git-svn-id: http://core.svn.wordpress.org/trunk@50230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
35 lines
643 B
JavaScript
35 lines
643 B
JavaScript
|
|
// Node.prototype.contains
|
|
(function() {
|
|
|
|
function contains(node) {
|
|
if (!(0 in arguments)) {
|
|
throw new TypeError('1 argument is required');
|
|
}
|
|
|
|
do {
|
|
if (this === node) {
|
|
return true;
|
|
}
|
|
// eslint-disable-next-line no-cond-assign
|
|
} while (node = node && node.parentNode);
|
|
|
|
return false;
|
|
}
|
|
|
|
// IE
|
|
if ('HTMLElement' in self && 'contains' in HTMLElement.prototype) {
|
|
try {
|
|
delete HTMLElement.prototype.contains;
|
|
// eslint-disable-next-line no-empty
|
|
} catch (e) {}
|
|
}
|
|
|
|
if ('Node' in self) {
|
|
Node.prototype.contains = contains;
|
|
} else {
|
|
document.contains = Element.prototype.contains = contains;
|
|
}
|
|
|
|
}());
|