Skip to content

jonathantneal/EventListener

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

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.

About

EventListener Polyfill for IE

Resources

License

Stars

Watchers

Forks

Packages

No packages published