Skip to content

Commit

Permalink
fix: make sure that document.createElement exists before using (#3706)
Browse files Browse the repository at this point in the history
If you try and require videojs in an environment that doesn't implement `document.createElement` properly -- like in Node.js -- you could potentially get an error. This checks that `window.document && window.document.createElement` is available before calling `createElement`.
We specifically check `window.document` so that `global` module won't cause issues with it's shimming of `document.createElement` in `global/document.

Fixes #3665
  • Loading branch information
gkatsev committed Oct 25, 2016
1 parent ac0329f commit 49e29ba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/js/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import xhr from 'xhr';
import Tech from './tech/tech.js';

// HTML5 Element Shim for IE8
if (typeof HTMLVideoElement === 'undefined') {
if (typeof HTMLVideoElement === 'undefined' &&
window.document &&
window.document.createElement) {
document.createElement('video');
document.createElement('audio');
document.createElement('track');
Expand Down

0 comments on commit 49e29ba

Please sign in to comment.