JSPM

@codevadmin/mdn-custom-event-polyfill

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q18014F
  • License MIT

MDN implementation of custom-event-polyfill for old browsers

Package Exports

  • @codevadmin/mdn-custom-event-polyfill

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@codevadmin/mdn-custom-event-polyfill) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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