Skip to content

Instantly share code, notes, and snippets.

@niczero
Created July 28, 2017 09:44
Show Gist options
  • Save niczero/6a78b427fadbc5d0b52800157980000f to your computer and use it in GitHub Desktop.
Save niczero/6a78b427fadbc5d0b52800157980000f to your computer and use it in GitHub Desktop.
Fix CustomEvent for older IE
(function () { // bootstrap CustomEvent for IE
if (typeof window.CustomEvent === 'function') return false;
function CustomEvent (event, params) {
params = params || {bubbles: false, cancelable: false, detail: undefined};
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype = window.Event.prototype;
window.CustomEvent = CustomEvent;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment