mdn-custom-event-polyfill
This is a MDN implementation of CustomEvent API for browsers that don't support it.
Intstall
Using yarn:
yarn add @codevadmin/mdn-custom-event-polyfill -S
Using npm:
npm i -S @codevadmin/mdn-custom-event-polyfill
Usage
Just import this polyfill before using any code with CustomEvent object.
import '@codevadmin/mdn-custom-event-polyfill';
const body = document.querySelector('body');
const payload = [0, 1, 2, 3];
const event = new CustomEvent('run', {
detail: {
payload,
},
});
body.dispatchEvent(event);
Support
It was successfully tested in IE 11. MDN tells the polyfill will work in IE 9+.