Created
October 17, 2018 12:58
-
-
Save tonysamperi/0e73f8489000e8261600a92af92748c1 to your computer and use it in GitHub Desktop.
new CustomEvent polyfill (new Event) for IE 9, IE10, IE11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Modern browsers already support new CustomEvent | |
* Remember to switch to CustomEvent in your application | |
*/ | |
// If IE | |
if (typeof w.CustomEvent !== typeof isNaN) { | |
const customEvent = function (event, params) { | |
params = params || {bubbles: false, cancelable: false, detail: undefined}; | |
const evt = document.createEvent("CustomEvent"); | |
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); | |
return evt; | |
}; | |
customEvent.prototype = w.Event.prototype; | |
w.CustomEvent = customEvent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment