Skip to content

Commit f19a701

Browse files
authored
Check for destroyed charts when handling throttled DOM events (#7293)
Co-authored-by: Evert Timberg <[email protected]>
1 parent ce902e1 commit f19a701

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/platform/platform.dom.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,12 @@ export default class DomPlatform extends BasePlatform {
386386
}
387387

388388
const proxy = proxies[type] = throttled((event) => {
389-
listener(fromNativeEvent(event, chart));
389+
// This case can occur if the chart is destroyed while waiting
390+
// for the throttled function to occur. We prevent crashes by checking
391+
// for a destroyed chart
392+
if (chart.ctx !== null) {
393+
listener(fromNativeEvent(event, chart));
394+
}
390395
}, chart);
391396

392397
addListener(canvas, type, proxy);

0 commit comments

Comments
 (0)