Skip to content

fix: unregister every listener in the receiver on off(event) - #109

Merged
luwes merged 1 commit into
masterfrom
fix/off-removes-all-listeners
Nov 3, 2026
Merged

luwes merged 1 commit into
masterfrom
fix/off-removes-all-listeners

Conversation

@luwes

@luwes luwes commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Player.off(event) (and off(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 as removeEventListener. 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: send removeEventListener for every removed listener, then return whether anything was removed. It also loops with an index instead of for...in over an array.
  • e2e/api.spec.ts: the test.fail() for this bug is now a regular test.

The return value is unchanged: true if any listener was removed, false otherwise.

There's no existing issue for this one. The new test suite found it.

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.
@luwes
luwes merged commit c5414a4 into master Nov 3, 2026
1 check passed
@luwes
luwes deleted the fix/off-removes-all-listeners branch November 3, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant