1(function(){ 2 3 if (window.NodeList && !NodeList.prototype.forEach) { 4 NodeList.prototype.forEach = Array.prototype.forEach; 5 } 6 7 if (!Element.prototype.matches) { 8 Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.msMatchesSelector; 9 } 10 11 // from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md 12 (function (arr) { 13 arr.forEach(function (item) { 14 if (item.hasOwnProperty('remove')) { 15 return; 16 } 17 Object.defineProperty(item, 'remove', { 18 configurable: true, 19 enumerable: true, 20 writable: true, 21 value: function remove() { 22 this.parentNode.removeChild(this); 23 } 24 }); 25 }); 26 })([Element.prototype, CharacterData.prototype, DocumentType.prototype]); 27 28 var supportsPassive = false; 29 try { 30 var opts = Object.defineProperty({}, 'passive', { 31 get: function() { 32 supportsPassive = true; 33 } 34 }); 35 window.addEventListener("testPassive", null, opts); 36 window.removeEventListener("testPassive", null, opts); 37 } catch (e) {} 38 39 40 var util = { 41 delegateEvent: function(eventName, selector, callback, el){ 42 el = el || document; 43 const realCallback = function(e) { 44 for (var target = e.target; target && target != this; target = target.parentNode) { 45 if (target.matches(selector)) { 46 callback.call(target, e); 47 break; 48 } 49 } 50 }; 51 el.addEventListener(eventName, realCallback, false); 52 return function(){ 53 el.removeEventListener(eventName, realCallback, false); 54 }; 55 }, 56 addPassiveEventListener: function(eventName, callback, el) { 57 el = el || document; 58 el.addEventListener(eventName, callback, supportsPassive ? { passive: true } : false); 59 }, 60 debounce: function(callback, delay, continuous){ 61 let running = undefined; 62 let pending = false; 63 return function(){ 64 if(!continuous && running){ 65 clearTimeout(running); 66 running = false; 67 } 68 if(!running){ 69 running = setTimeout(function(){ 70 running = false; 71 callback(); 72 if(pending){ 73 pending = false; 74 util.debounce(callback, delay); 75 } 76 }, delay); 77 }else { 78 pending = true; 79 } 80 } 81 }, 82 closest: function(el, selector){ 83 while (el && el.nodeType === 1) { 84 if (el.matches(selector)) { 85 return el; 86 } 87 88 el = el.parentNode; 89 } 90 return null; 91 }, 92 isVisible: function(el){ 93 return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length); 94 }, 95 triggerCustomEvent: function(eventName, detail, el){ 96 if (window.CustomEvent && typeof window.CustomEvent === 'function') { 97 var event = new CustomEvent(eventName, { 98 bubbles: true, 99 cancelable: true, 100 detail: detail 101 }); 102 } else { 103 var event = document.createEvent('CustomEvent'); 104 event.initCustomEvent(eventName, true, true, detail); 105 } 106 if(!el){ 107 el = document; 108 } 109 el.dispatchEvent(event); 110 return event; 111 }, 112 }; 113 114 window.jQueryPolyfill = util; 115 116})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.