summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/commons/polyfills/event.js
blob: ff5b9a1982f9d51de8eff12ce3f5543d4e041c3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * Polyfill for IE11 support.
 * new Event() is not supported by IE11.
 * Although `initEvent` is deprecated for modern browsers it is the one supported by IE
 */
if (typeof window.Event !== 'function') {
  window.Event = function Event(event, params) {
    const evt = document.createEvent('Event');
    const evtParams = {
      bubbles: false,
      cancelable: false,
      ...params,
    };
    evt.initEvent(event, evtParams.bubbles, evtParams.cancelable);
    return evt;
  };
  window.Event.prototype = Event;
}