Check for destroyed charts when handling throttled DOM events (#7293)

Co-authored-by: Evert Timberg <etimberg@opusonesolutions.com>
This commit is contained in:
Evert Timberg
2020-04-27 21:53:53 -04:00
parent cea43206e5
commit e457b3d3a0

View 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);