From 43113c9cd38722598668af08e19dbef6d363efdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Tusz?= Date: Tue, 10 May 2016 11:13:32 -0400 Subject: [PATCH] Promises: Ensure all `gd._promises` resolve before final resolve --- src/plot_api/plot_api.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 74e751b1030..6ecf45c4cdf 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -320,7 +320,7 @@ Plotly.plot = function(gd, data, layout, config) { gd.emit('plotly_afterplot'); } - var donePlotting = Lib.syncOrAsync([ + Lib.syncOrAsync([ Plots.previousPromises, marginPushers, marginPushersAgain, @@ -333,8 +333,9 @@ Plotly.plot = function(gd, data, layout, config) { // even if everything we did was synchronous, return a promise // so that the caller doesn't care which route we took - return (donePlotting && donePlotting.then) ? - donePlotting : Promise.resolve(gd); + return Promise.all(gd._promises).then(function() { + return gd; + }); }; // Get the container div: we store all variables for this plot as