Skip to content

Instantly share code, notes, and snippets.

@gt3
Last active March 1, 2022 11:50
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gt3/787767e8cbf0451716a189cdcb2a0d08 to your computer and use it in GitHub Desktop.
Save gt3/787767e8cbf0451716a189cdcb2a0d08 to your computer and use it in GitHub Desktop.
custom event polyfill for IE 11 (>= 9 really)
// source: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
;(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