wp-polyfill-node-contains.js 531 B

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