wp/wp-includes/js/dist/vendor/wp-polyfill-node-contains.js
changeset 18 be944660c56a
parent 9 177826044cd9
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
       
     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