From: Kevin Read Date: Fri, 17 Nov 2023 15:34:20 +0000 (+0100) Subject: fix: Guard access to window in helpers.dom.ts for browserless rendering (#11588) X-Git-Tag: v4.4.1~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e92d10445bc60af48dc9e4ae87b40d4193762ab9;p=thirdparty%2FChart.js.git fix: Guard access to window in helpers.dom.ts for browserless rendering (#11588) --- diff --git a/src/helpers/helpers.dom.ts b/src/helpers/helpers.dom.ts index ebd8d978d..c83712983 100644 --- a/src/helpers/helpers.dom.ts +++ b/src/helpers/helpers.dom.ts @@ -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 }