fix(evented): one() with multiple event types should not remove all listeners#9195
Closed
xxiaoxiong wants to merge 2 commits into
Closed
fix(evented): one() with multiple event types should not remove all listeners#9195xxiaoxiong wants to merge 2 commits into
xxiaoxiong wants to merge 2 commits into
Conversation
…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
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.
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 thelisten()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