W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2013

Re: Better event listeners

From: Anne van Kesteren <annevk@annevk.nl>
Date: Thu, 10 Jan 2013 13:47:09 +0100
Message-ID: <CADnb78iuSutNJtu+bgydh4_RL2y1KMWBxjju15Qkd_ki9=QtRw@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: Yehuda Katz <wycats@gmail.com>, DOM public list <www-dom@w3.org>
On Thu, Jan 10, 2013 at 3:35 AM, Jonas Sicking <jonas@sicking.cc> wrote:
> In order for that to work you need to do selector-based filtering of
> event.target, not event.currentTarget.

Yeah, my bad.


> Instead we should make it possible to at the time of registration,
> select whether the listener wants to listen to during the bubbling,
> target or capture phase. And maybe allow multiple phases. We could
> certainly have defaults based on the event type, but I think it should
> be possible to override that default.

Agreed.


> foo.addEventListener("click", object.clickhandler.bind(object));
>
> which is pretty verbose.

We discussed this in depth before when discussing the approach for
callbacks. We decided bind() was exactly the kind of feature that can
be used for this and maybe future editions of JavaScript should make
it easier to use, but that we would not try to work around it.


-- 
http://annevankesteren.nl/
Received on Thursday, 10 January 2013 12:47:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 10 January 2013 12:47:39 GMT