wp/wp-includes/js/dist/vendor/wp-polyfill-node-contains.js
changeset 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
       
     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 }());