From f19a701bc5c8c6da117871734e641bd8038fad07 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 27 Apr 2020 21:53:53 -0400 Subject: [PATCH] Check for destroyed charts when handling throttled DOM events (#7293) Co-authored-by: Evert Timberg --- src/platform/platform.dom.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/platform/platform.dom.js b/src/platform/platform.dom.js index e721c0c2c..ee5aafa80 100644 --- a/src/platform/platform.dom.js +++ b/src/platform/platform.dom.js @@ -386,7 +386,12 @@ export default class DomPlatform extends BasePlatform { } const proxy = proxies[type] = throttled((event) => { - listener(fromNativeEvent(event, chart)); + // This case can occur if the chart is destroyed while waiting + // for the throttled function to occur. We prevent crashes by checking + // for a destroyed chart + if (chart.ctx !== null) { + listener(fromNativeEvent(event, chart)); + } }, chart); addListener(canvas, type, proxy); -- 2.47.2