W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2009

[whatwg] Exposing EventTarget to JavaScript

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Fri, 24 Apr 2009 21:37:38 -0400
Message-ID: <49F26962.4080708@mit.edu>
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
Received on Friday, 24 April 2009 18:37:38 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:11 UTC