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

Package detail

event-listener-with-options

Macil14.5kMIT1.1.0TypeScript support: included

Polyfill for EventTarget options object support

addEventListener, removeEventListener, EventTarget, polyfill

readme

event-listener-with-options

GitHub license npm version CircleCI Status Greenkeeper badge

This module exports two functions:

  • addEventListener(target, type, handler, options)
  • removeEventListener(target, type, handler, options)

These work like target.addEventListener(type, handler, options), except that options is allowed to be an object even in browsers which don't yet support that. In that case, only the options object's capture property is respected.

See https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md for more information on the options parameter.

This module also includes an optional polyfill. Use the following to override the addEventListener and removeEventListener methods on all EventTargets with replacements that support an options object if necessary:

require('add-event-listener-with-options/js/polyfill');

Types

Both TypeScript and Flow type definitions for this module are included! The type definitions won't require any configuration to use.

changelog

1.1.0 (2018-09-26)

  • Added TypeScript type definitions.

1.0.4 (2018-06-04)

  • Lazily check for capture support. Avoids accessing DOM APIs during import, so merely importing won't break in non-browser environments, and possibly aids JS engine code caching.

1.0.3 (2017-07-07)

  • Updated Flow type definitions for Flow v0.49.1.

1.0.2 (2016-05-10)

Initial recommended stable release.