Skip to content

A full implementation of 'EventTarget' DOM interface that can be used anywhere.

License

Notifications You must be signed in to change notification settings

MarkMYoung/EventTargetImpl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EventTargetImpl

In short, all browsers provide an EventTarget implementation attached to DOM nodes, XmlHTTPRequests, etc.; however, one cannot simply perform new EventTarget(); (it throws TypeError). If one manages to get around that hurdle, perhaps by putting an DOM (input) element inside his class, he still cannot simply call eventTarget.dispatchEvent( 'eventName' ); (throws InvalidStateError). So, this is an implementation which should help with these limitations.

One can use this by containment,

function YourEventContainingClass()
{
  var eventTarget = new EventTarget();
}
YourEventContainingClass.prototype = Object.create( Object );
YourEventContainingClass.prototype.constructor = YourEventContainingClass;

by interface extension,

function YourEventExtendedClass()
{
  EventTarget.call( this );
}
YourEventExtendedClass.prototype = Object.create( Object );
YourEventExtendedClass.prototype.constructor = YourEventExtendedClass;

or by prototypical inheritance.

function YourEventInheritingClass()
{}
YourEventInheritingClass.prototype = Object.create( EventTargetImpl );
YourEventInheritingClass.prototype.constructor = YourEventInheritingClass;

//: # ( Build Status )

About

A full implementation of 'EventTarget' DOM interface that can be used anywhere.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages