Created
March 30, 2017 18:07
-
-
Save leemark/777b5ce94bce409b5f208c924bb5878b to your computer and use it in GitHub Desktop.
Polyfill for CustomEvent constructor in IE9-11. All credit to: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
This file contains hidden or 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
(function () { | |
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