delegate.js
delegate.js copied to clipboard
Doesn't support EventListener interface
An object that implements EventListener interface (https://developer.mozilla.org/en-US/docs/Web/API/EventListener) has a handleEvent
method. e.g.:
var obj = {
log : function(e) {
console.log("event", e.type, "happened on", e.target);
},
handleEvent : function(e) {
this.log(e);
}
};
Notice that the this
value in handleEvent
is bound to the object itself. As obj
implements the EventListener interface, it can be registered directly as an event listener:
document.addEventListener("click", obj, false);
It would be great if the EventListener interface was respected by delegate.js and worked as one would expect:
delegate(body).on("click", ".some-selector", obj);
Sounds good.