Re: Better event listeners

On Tue, Feb 12, 2013 at 8:33 AM, Anne van Kesteren <> wrote:

> On Tue, Feb 12, 2013 at 2:23 PM, Glenn Maynard <> wrote:
> > It doesn't work completely differently.  It works exactly the same.
> > addEventListener("click", func, true) would be exactly equivalent to
> > addEventListener("click", func, {capture: true}).
> Yes, but it would also return an object (for which it's not at all
> clear that's web compatible). And I think if the preferred API is
> going to support event delegation we should also by default ignore
> bubbles.

No, addEventListener would always return the object, not just when it takes
an object.  That's just adding an orthogonal feature to the method.
(Whether there's code out there somehow depending on addEventListener's
lack of return value is a separate question; I don't know, of course.)

Ignoring bubbles by default makes me a little nervous, since it's a subtle
difference between very similar APIs which people less experienced with DOM
events won't necessarily understand.  Either way, though, having a
different default doesn't seem like a good reason to have a completely
separate API.

Glenn Maynard

Received on Tuesday, 12 February 2013 15:02:16 UTC