Re: [whatwg/dom] Removing event listeners through an identifier (#208)

@LeaVerou:

Regarding multiple listeners:

It appears that Web IDL already distinguishes iterables and strings. So we can say `groups: ["foo", "bar"]` or `groups: "foo"`. I'm not sure about the pluralization (should it be `group`, or `groups`?).

I also don't think it's a good idea to allow removing multiple groups using `removeEventListener`, because the semantics as you've described them are so different from those of `addEventListener`. `addEventListener(type, cb, { groups: ["foo", "bar"] })` adds something with group `"foo"` and group `"bar"`. Wheras `removeEventListener({ groups: ["foo", "bar"] })` would, if I understand correctly, remove events with _either_ `"foo"` or `"bar"`. So I think if we allow passing multiple groups to `removeEventListener`, it should use the same semantics as `addEventListener`, and remove events with _both_ `"foo"` and `"bar"`. But maybe that's too confusing, so we should only support passing a single group value.

As for the name, that's negotiable, but the other two options (`class` and `tag`) seem worse to me. jQuery calls them "namespaces" in the docs (but does not reify that name in the API), which seems particular bad in the DOM context, so we shouldn't do that.

Unless we have some persuasive arguments for a different name, I'd prefer sticking with either `group` or `groups`.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/208#issuecomment-311488073

Received on Tuesday, 27 June 2017 21:17:22 UTC