Repository navigation
fix: unregister every listener in the receiver on off(event) - #109
Merged
Merged
Conversation
Player.off() returned inside its loop, so only the first listener id was sent to the iframe as removeEventListener. The others stayed registered in the receiver and kept posting events that nothing handled. Send removeEventListener for every removed listener, and loop with an index instead of for...in over the array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Player.off(event)(andoff(event, cb)when the same callback was added more than once) returned inside its loop. Only the first listener id was sent to the iframe asremoveEventListener. The rest stayed registered in the receiver, which kept posting events to the parent after the caller had unsubscribed.They didn't reach any callbacks, because they were removed locally, but the receiver kept doing the work and sending the messages for as long as the page was open.
src/player.js: sendremoveEventListenerfor every removed listener, then return whether anything was removed. It also loops with an index instead offor...inover an array.e2e/api.spec.ts: thetest.fail()for this bug is now a regular test.The return value is unchanged:
trueif any listener was removed,falseotherwise.There's no existing issue for this one. The new test suite found it.