From f9a27805468754f2e1927a8b95c0f18b01f97c50 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 28 Feb 2018 23:24:53 +0100 Subject: [PATCH] Do not assume window is defined It is notably not the case in web workers. --- src/ol/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/index.js b/src/ol/index.js index f2e44acc19..377d594239 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -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'));