W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2012

Add extra argument to addEventListener with the context

From: Elliott Sprehn <esprehn@gmail.com>
Date: Fri, 15 Jun 2012 10:21:07 -0700
Message-ID: <CAPJYB1jf2dX9VhP3NX=zWCR3LDfyKBrN2bac+WJ_kAgqZijYTA@mail.gmail.com>
To: www-dom <www-dom@w3.org>
Google Closure supports an additional final argument to addEventListener
that's the context the method is called with:

target.addEventListener(event, fn, capture, context)

So you could do

target.addEventListener(event, this.handleClick, false, this);

and later

target.removeEventListener(event, this.handleClick, false, this);

It'd be nice to get native support since it makes adding and removing
listeners easier.

- E
Received on Friday, 15 June 2012 17:21:55 GMT

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