- From: Timo Tijhof <notifications@github.com>
- Date: Tue, 27 Jun 2017 16:22:26 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/208/311513099@github.com>
@LeaVerou Yeah, this decision isn't unique to multiple groups. In fact, it isn't even unique to the `group` option. Consider the following ```js el.addEventListener("type", cb); el.addEventListener("type", cb); ``` The current behaviour is that the callback is not added a second time. Which means it still gets fired only once per event, regardless of having tried to "add" it twice. And this also applies to other options that exist today. ```js el.addEventListener("type", cb); el.addEventListener("type", cb, { once: true }); el.addEventListener("type", cb); el.addEventListener("type", cb, { once: true }); ``` Results in one regular listener, and one "once" listener. The callback isn't the only value compared to decide unique-ness of the listener set. Instead, it is based on all options together. We can do the same for groups. That means, just like today with other options, if you add the exact same set of options + callback, it is ignored. If any aspect is different, it becomes a new separate listener. The registry remains unique on all factors combined, regardless of group being 1 or multiple strings. ```js el.addEventListener("type", cb, { group: [ 'a', 'b' ] }); el.removeEventListener("type", { group: 'a' }); ``` Assuming we want to support the above case, browser have to inspect the data (look into the arrays and possibly normalise), as opposed to merely comparing the input to the stored value - in that case it would only be possible to remove the listener if you supply the same group array as input (and strings in the same order). That isn't too unreasonable in my opinion, but depends on the use cases. One the one hand one could argue that finding stuff tagged with A and removing it, should work. On the other hand one could argue that if group B loses interest, that doesn't mean group A is no longer interested. If that is the direction we want to go in, we'd have to complicate it more by only removing listeners once all groups have been "removed". -- 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-311513099
Received on Tuesday, 27 June 2017 23:22:58 UTC