Skip to content

Commit a7277c2

Browse files
committed
Fix Plotly.plot promise chain and test with mathjax image
1 parent b04a331 commit a7277c2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/plot_api/plot_api.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Plotly.plot = function(gd, data, layout, config) {
107107
// any part of the plotting code can push to gd._promises, then
108108
// before we move to the next step, we check that they're all
109109
// complete, and empty out the promise list again.
110-
gd._promises = [];
110+
if(!Array.isArray(gd._promises)) gd._promises = [];
111111

112112
var graphWasEmpty = ((gd.data || []).length === 0 && Array.isArray(data));
113113

@@ -384,14 +384,16 @@ Plotly.plot = function(gd, data, layout, config) {
384384
drawData,
385385
finalDraw,
386386
initInteractions,
387-
Plots.rehover
387+
Plots.rehover,
388+
Plots.previousPromises
388389
];
389390

390-
Lib.syncOrAsync(seq, gd);
391-
392391
// even if everything we did was synchronous, return a promise
393392
// so that the caller doesn't care which route we took
394-
return Promise.all(gd._promises).then(function() {
393+
var plotDone = Lib.syncOrAsync(seq, gd);
394+
if(!plotDone || !plotDone.then) plotDone = Promise.resolve();
395+
396+
return plotDone.then(function() {
395397
gd.emit('plotly_afterplot');
396398
return gd;
397399
});

test/image/baselines/mathjax.png

63.3 KB
Loading

0 commit comments

Comments
 (0)