1
0
mirror of https://github.com/videojs/video.js.git synced 2025-07-09 01:15:31 +02:00

fix: Support require()-ing video.js (#3889)

Introduce the Dom.isReal() function, which makes an educated assumption about the "realness" of the document object.
Wrap code here and there with checks against Dom.isReal() as well as other defensive code.

Fixes #3869.
This commit is contained in:
Pat O'Neill
2016-12-23 11:30:49 -05:00
committed by Gary Katsevman
parent b7c384eb5b
commit ac0b03f2f7
5 changed files with 53 additions and 30 deletions

View File

@ -2,7 +2,7 @@
* @file browser.js
* @module browser
*/
import document from 'global/document';
import * as Dom from './dom';
import window from 'global/window';
const USER_AGENT = window.navigator && window.navigator.userAgent || '';
@ -70,5 +70,11 @@ export const IE_VERSION = (function(result) {
export const IS_SAFARI = (/Safari/i).test(USER_AGENT) && !IS_CHROME && !IS_ANDROID && !IS_EDGE;
export const IS_ANY_SAFARI = IS_SAFARI || IS_IOS;
export const TOUCH_ENABLED = !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch);
export const BACKGROUND_SIZE_SUPPORTED = 'backgroundSize' in document.createElement('video').style;
export const TOUCH_ENABLED = Dom.isReal() && (
'ontouchstart' in window ||
window.DocumentTouch &&
window.document instanceof window.DocumentTouch);
export const BACKGROUND_SIZE_SUPPORTED = (
Dom.isReal() &&
'backgroundSize' in window.document.createElement('video').style);