[whatwg] Exposing EventTarget to JavaScript

Boris Zbarsky bzbarsky at MIT.EDU
Fri Apr 24 18:37:38 PDT 2009


Ojan Vafai wrote:
> What would be a better approach?

I believe Alex proposed some in this thread as aliases for 
addEventListener.  Those looked a lot better to me, for what it's worth.

If a linear list of things the event is targeting is sufficient, of 
course, and we're ok with the random third argument of addEventListener 
being carted around, then we might be ok using it...

 From my point of view, in addition to the things already mentioned, an 
issue with addEventListener is that removing requires a match of both 
the listener and the bubbles arg.  So for example:

   node.addEventListener("foo", function() { ... }, false);

if I want to remove it later, I suddenly have to pull the function out 
and give it a name.  And then on the remove end duplicate the "foo" and 
false. Maybe it's just me, but I'd have much preferred something like:

   var token = node.addEventListener("foo", function() { ... });

   // later on
   node.removeEventListener(token);

or some such.

-Boris



More information about the whatwg mailing list