Skip to content

fix(evented): one() with multiple event types should not remove all listeners#9195

Closed
xxiaoxiong wants to merge 2 commits into
videojs:mainfrom
xxiaoxiong:fix/one-multi-event-types-9183
Closed

fix(evented): one() with multiple event types should not remove all listeners#9195
xxiaoxiong wants to merge 2 commits into
videojs:mainfrom
xxiaoxiong:fix/one-multi-event-types-9183

Conversation

@xxiaoxiong

Copy link
Copy Markdown

Fixes #9183
Closes #5962

Description

When one() is called with multiple event types targeting another evented object (e.g. player.one(target, ['play', 'pause'], callback)), a single wrapper function was shared across all event types via the listen() call. When any one of the events fired, the wrapper removed itself for all event types, preventing the remaining events from ever triggering.

The bug was already acknowledged in a TODO comment referencing #5962.

Changes

  • src/js/mixins/evented.js: Create a separate wrapper per event type when targeting another evented object, so each event type only removes its own wrapper when triggered.

Testing

  • Single event type continues to work as before
  • Multiple event types now each correctly fire once
  • Wrapper GUID is preserved for proper cleanup

…back

Fixes #9187

The this.tech_.any() callback is set up asynchronously. If the tech is
disposed before the callback fires, this.tech_ may be false and
this.lastSource_ may be invalid, causing errors when accessing
this.techGet_('currentSrc') and this.lastSource_.tech.

Add an early return guard when this.tech_ is falsy.
…isteners

When one() was called with multiple event types targeting another evented
object (e.g. `player.one(target, ['play', 'pause'], callback)`), a single
wrapper function was shared across all event types. When any event fired,
the wrapper removed itself for ALL event types, preventing the remaining
events from ever triggering.

This creates a separate wrapper per event type, so that each event type
only removes its own wrapper when triggered.

Fixes #9183
Closes #5962
@xxiaoxiong xxiaoxiong closed this May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant