Skip to content

Commit

Permalink
fix: allow Video.js to be required in an env without setTimeout (#7247)
Browse files Browse the repository at this point in the history
Some JavaScript environments don't implement setTimeout, which causes Video.js to fail on require. Instead, move our Dom.isReal() check earlier to before we call setTimeout.
  • Loading branch information
tf committed Jun 2, 2021
1 parent 41d5eb3 commit 8082c5a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/js/setup.js
Expand Up @@ -16,8 +16,7 @@ let videojs;
*/
const autoSetup = function() {

// Protect against breakage in non-browser environments and check global autoSetup option.
if (!Dom.isReal() || videojs.options.autoSetup === false) {
if (videojs.options.autoSetup === false) {
return;
}

Expand Down Expand Up @@ -71,6 +70,11 @@ const autoSetup = function() {
* The videojs library function
*/
function autoSetupTimeout(wait, vjs) {
// Protect against breakage in non-browser environments
if (!Dom.isReal()) {
return;
}

if (vjs) {
videojs = vjs;
}
Expand Down

0 comments on commit 8082c5a

Please sign in to comment.