PageSourceSearch

https://cm.theleafchronicle.com/node_modules/custom-event-polyfill/polyfill.js

js theleafchronicle.com collected 2026-09-24 08:41:13 UTC 1,475 bytes, 55 lines download raw bytes

vendor: 1,475 bytes, lines 1-55
1// Polyfill for creating CustomEvents on IE9/10/11
2
3// code pulled from:
4// https://github.com/d4tocchini/customevent-polyfill
5// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill
6
7(function() {
8  if (typeof window === 'undefined') {
9    return;
10  }
11
12  try {
13    var ce = new window.CustomEvent('test', { cancelable: true });
14    ce.preventDefault();
15    if (ce.defaultPrevented !== true) {
16      // IE has problems with .preventDefault() on custom events
17      // http://stackoverflow.com/questions/23349191
18      throw new Error('Could not prevent default');
19    }
20  } catch (e) {
21    var CustomEvent = function(event, params) {
22      var evt, origPrevent;
23      params = params || {
24        bubbles: false,
25        cancelable: false,
26        detail: undefined
27      };
28
29      evt = document.createEvent('CustomEvent');
30      evt.initCustomEvent(
31        event,
32        params.bubbles,
33        params.cancelable,
34        params.detail
35      );
36      origPrevent = evt.preventDefault;
37      evt.preventDefault = function() {
38        origPrevent.call(this);
39        try {
40          Object.defineProperty(this, 'defaultPrevented', {
41            get: function() {
42              return true;
43            }
44          });
45        } catch (e) {
46          this.defaultPrevented = true;
47        }
48      };
49      return evt;
50    };
51
52    CustomEvent.prototype = window.Event.prototype;
53    window.CustomEvent = CustomEvent; // expose definition to window
54  }
55})();

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.