Do not assume window is defined

It is notably not the case in web workers.
This commit is contained in:
Guillaume Beraudo
2018-02-28 23:24:53 +01:00
parent cfa9718df9
commit f9a2780546

View File

@@ -41,7 +41,7 @@ let WEBGL_EXTENSIONS; // value is set below
let HAS_WEBGL = false;
if ('WebGLRenderingContext' in window) {
if (typeof window !== 'undefined' && 'WebGLRenderingContext' in window) {
try {
const canvas = /** @type {HTMLCanvasElement} */
(document.createElement('CANVAS'));