-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(fromEvent): pass options in unsubscribe #3350
Conversation
So actually MDN describes this topic already: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener
Change looks legit to me. |
Generated by 🚫 dangerJS |
@@ -206,7 +206,7 @@ export class FromEventObservable<T> extends Observable<T> { | |||
} else if (isEventTarget(sourceObj)) { | |||
const source = sourceObj; | |||
sourceObj.addEventListener(eventName, <EventListener>handler, <boolean>options); | |||
unsubscribe = () => source.removeEventListener(eventName, <EventListener>handler); | |||
unsubscribe = () => source.removeEventListener(eventName, <EventListener>handler, <boolean>options); |
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.
The options
aren't necessarily a boolean
, they can be an EventListenerOptions
object as well.
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.
I'm unaware of why the boolean
assertion was used in the original code's call to the addEventListener
method. Perhaps the typings in an earlier version of TypeScript were not representative of the API? The current typings seem okay, so I guess this could be changed. However, it is only a type assertion and has no runtime effect.
Thanks, @cartant! :) |
@benlesh Before I rebased this PR - to accommodate the refactorings in master - it would have be cherry-pickable into stable. Do you see any need for another PR to fix this in stable, too? |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description:
Fixes the problem reported in #3349. In Chrome, at least, if options are passed in the call to
addEventListener
, but not in the call toremoveEventListener
, the listener is not removed.The PR adds an expectation to an existing test and passes the options in the call to
removeEventListener
, too.Related issue (if exists): #3349