Multimedia player: Fix AJAX race condition in Firefox #9329
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.
Players brought in via the Data Ajax plugin sometimes tried initializing themselves twice in Firefox.
When it happened, the first attempt occurred before the AJAXed-in player had received a "wb-auto-*" ID - resulting in the player and media element's IDs getting set to "undefined" and "undefined-md" respectively.
The second attempt then treated the player's transformed HTML markup as if it was the initial markup. That caused several issues, such as a "video" class getting added to audio players (producing a large play icon overlapping the player controls), ID mismatches and a JavaScript console error related to the
media
variable being undefined.This resolves it via the following changes:
media
variable is truthy before proceeding with initializationmedia
checkwb.getId()
if the player doesn't already have onemedia
check is still necessary for players that use hardcoded IDs.media.currentSrc
in the condition that triggersrenderUIEvent
(speeds things up by triggering it on the first init instead of the second, higher-levelmedia
check makes this one redundant)