Welcome to mirror list, hosted at ThFree Co, Russian Federation.

event.js « polyfills « commons « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 543dd5f9a93382b645bb08f815db4a43a0954950 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
 * Polyfill: Event constructor
 * @what new Event()
 * @why To align browser support
 * @browsers Internet Explorer 11
 * @see https://caniuse.com/#feat=mdn-api_event_event
 *
 * 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;
}