]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
fix: Guard access to window in helpers.dom.ts for browserless rendering (#11588)
authorKevin Read <me@kevin-read.com>
Fri, 17 Nov 2023 15:34:20 +0000 (16:34 +0100)
committerGitHub <noreply@github.com>
Fri, 17 Nov 2023 15:34:20 +0000 (16:34 +0100)
src/helpers/helpers.dom.ts

index ebd8d978d9146cae6b53acb584632941dbe81620..c83712983acab6ee6451645a7e085b9829ca86a4 100644 (file)
@@ -262,8 +262,10 @@ export const supportsEventListenerOptions = (function() {
       }
     } as EventListenerOptions;
 
-    window.addEventListener('test', null, options);
-    window.removeEventListener('test', null, options);
+    if (_isDomSupported()) {
+      window.addEventListener('test', null, options);
+      window.removeEventListener('test', null, options);
+    }
   } catch (e) {
     // continue regardless of error
   }