Re: Adding an interface to provide a list of listeners

27.07.2014, 21:42, "Anne van Kesteren" <annevk@annevk.nl>:
> On Sun, Jul 27, 2014 at 7:08 PM, Marat Tanalin <mtanalin@yandex.ru> wrote:
>> šCloning the original element and replacing it with the clone (a workaround typically used currently to remove listeners) is probably worse than a possible standard way to expose listeners to allow legitimate direct removal of just listeners without such unneeded (and probably at least slower) workarounds.
>
> I don't see a problem with having better methods of removing listeners.

Nice. For this purpose, it would be fine and natural for me just to make second argument for `removeEventListener()` optional. So if specific listener is not specified, then all listeners of the specified event type are removed at once:


    // Removes all `click` listeners.
    element.removeEventListener('click');

First argument could probably be made optional too (it's not as critical, but still desirable) to be able to remove all listeners at once regardless of their type (like if the element has been cloned and replaced with the clone):

    // Removes all listeners of all types.
    element.removeEventListener();

Thanks.

Received on Sunday, 27 July 2014 23:57:15 UTC