Skip to content

Commit 31a77ac

Browse files
committed
Improve robustness for dangling callbacks on Plotly.purge
1 parent 0616495 commit 31a77ac

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/plots/plots.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,10 @@ plots.purge = function(gd) {
10871087
if(fullLayout._glcontainer !== undefined) fullLayout._glcontainer.remove();
10881088
if(fullLayout._geocontainer !== undefined) fullLayout._geocontainer.remove();
10891089

1090+
// Ensure any dangling callbacks are simply dropped if the plot is purged.
1091+
// This is more or less only actually important for testing.
1092+
gd._transitionData._interruptCallbacks.length = 0;
1093+
10901094
// remove modebar
10911095
if(fullLayout._modeBar) fullLayout._modeBar.destroy();
10921096

@@ -1787,6 +1791,11 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts)
17871791
}
17881792

17891793
function completeTransition(callback) {
1794+
// This a simple workaround for tests which purge the graph before animations
1795+
// have completed. That's not a very common case, so this is the simplest
1796+
// fix.
1797+
if(!gd._transitionData) return;
1798+
17901799
flushCallbacks(gd._transitionData._interruptCallbacks);
17911800

17921801
return Promise.resolve().then(function() {

0 commit comments

Comments
 (0)