Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@codevadmin/mdn-custom-event-polyfill

dadmin19MIT1.0.1

MDN implementation of custom-event-polyfill for old browsers

polyfill, CustomEvent, commonJS, webpack, module, Web API Interface

readme

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+.