return already created player when given an element #3006
Closed
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.
As part of the tech 2.0 work, we decided to remote the player out of the tech. One of the changes in it nulled out
tag.player
. This is an issue becausevideojs(el)
usestag.player
to see whether we have already created, so, if you try to get the player again with the sameel
, it'll actually create a brand new player for you.An example:
The expected result should be something like this:
There are two ways I can think off right now to fix this:
tag.player
tag.player
in null, we would want to parse out the id to remove the stuff likehtml5_api
and then returnvideojs.players[parsedId(tag.id)]
if it exists, otherwise actually go ahead and create a playerI feel like solution number 2 is more correct but it is also a lot more complicated and more prone to issues. Included below right now are two failing tests for the above usecase.
@videojs/core-committers @dconnolly thoughts?