<span class="Apple-style-span" style="border-collapse: collapse; "><div class="gmail_quote"><div class="im" style="color: rgb(80, 0, 80); ">On Fri, Apr 24, 2009 at 6:37 PM, Boris Zbarsky <span dir="ltr"><<a href="mailto:bzbarsky@mit.edu" target="_blank" style="color: rgb(7, 77, 143); ">bzbarsky@mit.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<div>Ojan Vafai wrote:<br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
What would be a better approach?<br></blockquote><br></div>I believe Alex proposed some in this thread as aliases for addEventListener. Those looked a lot better to me, for what it's worth.</blockquote><div><br></div>
</div><div>I have no problem with adding these aliases as long as the DOM and JS APIs match. I agree that listen/unlisten are better names.</div><div class="im" style="color: rgb(80, 0, 80); "><div><br></div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
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...</blockquote><div><br></div>
</div><div>I think this is sufficient. Although it is a bit unfortunate that dispatch order is undefined. It would be great if we could just agree that dispatch order is the order the handlers were registered in. I don't know the technical details here though. Is there a reason that they can't dispatch in a guaranteed order?</div>
<div class="im" style="color: rgb(80, 0, 80); "><div><br></div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
>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:<br><br> node.addEventListener("foo", function() { ... }, false);<br>
<br>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:<br>
<br> var token = node.addEventListener("foo", function() { ... });<br><br> // later on<br> node.removeEventListener(token);<br></blockquote></div></div><br><div>Yes, I completely agree that this is a significant shortcoming of addEventListener. It seems like we could safely add this to the current API.</div>
<div><br></div><div>In short, I'm happy with evolving addEventListener to make it suck less if we can keep the JS and DOM APIs consistent.</div><div><br></div><font color="#888888"><div>Ojan</div></font></span>