From: Evert Timberg Date: Tue, 28 Apr 2020 01:53:53 +0000 (-0400) Subject: Check for destroyed charts when handling throttled DOM events (#7293) X-Git-Tag: v3.0.0-beta.2~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f19a701bc5c8c6da117871734e641bd8038fad07;p=thirdparty%2FChart.js.git Check for destroyed charts when handling throttled DOM events (#7293) Co-authored-by: Evert Timberg --- 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);