EventListener Polyfill for IE
JavaScript HTML
Switch branches/tags
Nothing to show
Latest commit 9802db1 Jan 30, 2016 @jonathantneal Merge pull request #15 from pospi/master
Fix event attribute access outside of callbacks
Permalink
Failed to load latest commit information.
Demo.html Demo Nov 20, 2012
EventListener.js Merge pull request #15 from pospi/master Jan 30, 2016
EventListener.oldie.js Add CC0-1.0 license #16 Aug 7, 2014
LICENSE.md Add CC0-1.0 license #16 Aug 7, 2014
README.md Documentation Nov 20, 2012
bower.json Create bower.json Aug 7, 2014

README.md

EventListener Polyfill

Is IE8 your new IE6? Level the playing field with polyfills.

Is IE6 still your IE6? You're covered too now.

This script polyfills addEventListener, removeEventListener, dispatchEvent, CustomEvent, and DOMContentLoaded. It is less than half a kilobyte minified and gzipped.

addEventListener

addEventListener registers an event listener on a target.

Syntax

target.addEventListener(type, listener);
  • type: A string representing the event type to listen for.

  • listener: The object that receives a notification when an event of the specified type occurs. This must be an object implementing the EventListener interface, or simply a JavaScript function.

It should be noted that useCapture has not been polyfilled.

removeEventListener

removeEventListener unregisters an event listener on a target.

Syntax

target.removeEventListener(type, listener);
  • type: A string representing the event type being removed.

  • listener: The EventListener object or function to be removed.

It should be noted that useCapture has not been polyfilled.

dispatchEvent

Dispatches an event into the event system. The event is subject to the same capturing and bubbling behavior as directly dispatched events.

Syntax

bool = target.dispatchEvent(event);
  • event: An event object to be dispatched.

It should be noted that document.createEvent has not been polyfilled.

CustomEvent

A custom event to be initialized by dispatchEvent.

var event = new CustomEvent(type, canBubble, cancelable, details);
  • type: A string representing the event type.

  • canBubble: A boolean indicating whether the event bubbles up through the DOM or not.

  • cancelable: A boolean indicating whether the event is cancelable.

  • details: Additional data passed into the custom event.