W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2011

Re: EventTarget.on

From: Glenn Maynard <glenn@zewt.org>
Date: Wed, 23 Nov 2011 11:13:50 -0500
Message-ID: <CABirCh8bX6_pS-U6s9RAn70rULLDH-Oa9HMhSEF+qquG4rtUXg@mail.gmail.com>
To: Anne van Kesteren <annevk@opera.com>
Cc: www-dom@w3.org, Jake Verbaten <raynos2@gmail.com>
On Wed, Nov 23, 2011 at 6:40 AM, Anne van Kesteren <annevk@opera.com> wrote:

> On Mon, 21 Nov 2011 16:13:02 +0100, Jake Verbaten <raynos2@gmail.com>
> wrote:
>
>> addEventListener is long and verbose. Could we have `on` as a synonym for
>> addEventListener ?
>>
>
"on" is a method added to Element.prototype by jQuery and Prototype, so
this seems like it would just be asking for problems and confusion.

 I think it should have additional functionality if we are going to add
> something new. E.g. ignore whether the event was dispatched as a bubbling
> event or not and have it always go through the bubble phase.


I suspect a lot of people would benefit from this, since there's a tension
between how events are used: some uses want certain events to not bubble
(especially on* handlers), and others, like event delegation, want every
event to bubble.

I don't think this needs a new method, though.

elem.addEventListener("event", func, { forceBubble: true, capture: false });

Maybe add the possibility of only invoking the listener when it is
> registered on the actual event target, things like that.
>

I've always thought that addEventListener's capture flag could be more
generic: specify which dispatch phases the event listener should be fired
during, as a mask of capture, at and bubble.  (For this case, you'd set
only the "at" phase.  Normal capture is capture|at; normal non-capture is
bubble|at.)  That wouldn't need a new method, either, though.

It's been a while since I've wanted that, and I don't remember why I needed
it, so it's just a thought.

-- 
Glenn Maynard
Received on Wednesday, 23 November 2011 16:14:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:08 GMT