]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Check for destroyed charts when handling throttled DOM events (#7293)
authorEvert Timberg <evert.timberg+github@gmail.com>
Tue, 28 Apr 2020 01:53:53 +0000 (21:53 -0400)
committerGitHub <noreply@github.com>
Tue, 28 Apr 2020 01:53:53 +0000 (21:53 -0400)
Co-authored-by: Evert Timberg <etimberg@opusonesolutions.com>
src/platform/platform.dom.js

index e721c0c2c1cf372fce506f43d78f6b43d728090e..ee5aafa80830ca2b975aa7d030827b01957bb2e4 100644 (file)
@@ -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);