mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-20 15:16:51 +01:00
Check for destroyed charts when handling throttled DOM events (#7293)
Co-authored-by: Evert Timberg <etimberg@opusonesolutions.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user