1(function (window, document) { 2 'use strict'; 3 4 // Compatibility shim for third-party delegated event handlers that call 5 // event.target.closest() when the target can be a non-Element EventTarget 6 // (for example a text node). Only adds the method when it is missing. 7 if (!window || !window.EventTarget || !window.Element || !window.Element.prototype.closest) { 8 return; 9 } 10 11 if (typeof window.EventTarget.prototype.closest !== 'function') { 12 var nativeClosest = window.Element.prototype.closest; 13 try { 14 Object.defineProperty(window.EventTarget.prototype, 'closest', { 15 configurable: true, 16 writable: true, 17 value: function (selector) { 18 var node = this; 19 if (!node) { 20 return null; 21 } 22 if (node.nodeType !== 1) { 23 node = node.parentElement || node.parentNode; 24 } 25 if (!node || node.nodeType !== 1) { 26 return null; 27 } 28 return nativeClosest.call(node, selector); 29 } 30 }); 31 } catch (e) { 32 // Older/locked environments may reject prototype extension. 33 // Clockinator functionality does not depend on this shim. 34 } 35 } 36})(window, document);
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.