-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow removing event listeners by group #469
Conversation
a874687
to
48b1053
Compare
( This is a pull request so try to not comment API proposal here. ) |
dom.bs
Outdated
to remove all event listeners in that group: | ||
|
||
<pre class=lang-javascript> | ||
oven.addEventListener("turnon", () => { … }, { group: "cookies" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cookies
is a fun and lightweight example word, but I think in this context it has the risk of confusing less-experienced readers due to being an overloaded term. Perhaps we can come up with another example here, or if nothing else, plain "example"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Will make it brownies instead during the next revision.
48b1053
to
9400bac
Compare
I was wondering whether supplying a signal like the AbortController/AbortSignal would make more sense instead of groups. Then you can abort multiple things with the same controller.
|
I suggest we close this now that you can use abort signals as grouping mechanism thanks to @benjamingr's work. Thoughts? |
Oh, right, this was mine originally. Yeah, signals is basically a better version of this; let's close! |
Closes #208.
Tests: web-platform-tests/wpt#6331
Chrome is tentatively interested in this, although the first step is getting a spec and tests up for review. Would love to hear if other implementers are interested--- @smaug----, @cdumez, @travisleithead?
I decided to go with an overload instead of a new method, so we can leave new method names for something potentially nicer like
on
/off
. Overloading for this pattern is pretty common, e.g. it is what jQuery does. And introducing two similar-but-different method names likeremoveEventListener
+deleteEventListener
seemed like a bad idea.I also added an overload
removeEventListener(type, { group })
which is not really necessary. We could get rid of that if we don't like it. But it fell out naturally.This also preserves what I'm pretty sure is a bug, per #468, but at least it centralizes the probably-buggy check.
Preview | Diff