W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2014

Re: Adding an interface to provide a list of listeners

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Sun, 27 Jul 2014 18:12:16 -0700
Message-ID: <CAAWBYDDxZ8duYBaENG1E1Q7hUG-F_r6xpOzp6ph1R6qEvHv8Ww@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: "www-dom@w3.org" <www-dom@w3.org>
On Sun, Jul 27, 2014 at 6:08 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 7/27/14, 7:56 PM, Marat Tanalin wrote:
>> So if specific listener is not specified, then all listeners of the
>> specified event type are removed at once:
> This seems like a footgun, no?  One library adds some listeners, then
> another adds some, then the first removes them all, breaking the second
> library.
> Or worse yet you do this on a <select size="1"> and remove the click event
> listener that opens the dropdown...
> Or did you not actually mean _all_ listeners?  Perhaps you meant "all the
> listeners that this script (or this function or some other unit of related
> code yet to be defined) has added"?

Yeah, probably better to add an optional "namespacing" string to
addEventListener, and then removeEventListener can kill all listeners
with the same namespace string.  (Allow Symbols as well as strings,
and you safeguard UA listeners without magic.)

Received on Monday, 28 July 2014 01:13:03 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:23 UTC