Skip to content

Commit deb32ff

Browse files
committed
Plots.resize: reject old promises
1 parent 5ef8a61 commit deb32ff

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/plots/plots.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ plots.resize = function(gd) {
8181
reject(new Error('Resize must be passed a displayed plot div element.'));
8282
}
8383

84+
if(gd._rejectResize) gd._rejectResize();
85+
gd._rejectResize = reject;
86+
8487
if(gd._redrawTimer) clearTimeout(gd._redrawTimer);
8588

8689
gd._redrawTimer = setTimeout(function() {

test/jasmine/tests/plots_test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,27 @@ describe('Test Plots', function() {
412412
.then(done);
413413
});
414414
});
415+
416+
describe('returns Promises', function() {
417+
afterEach(destroyGraphDiv);
418+
419+
it('should reject or resolve them all', function(done) {
420+
gd = createGraphDiv();
421+
var p = [];
422+
Plotly.newPlot(gd, [{y: [5, 2, 5]}])
423+
.then(function() {
424+
// First call should get rejected
425+
p.push(Plotly.Plots.resize(gd).catch(function() {
426+
return Promise.resolve(true);
427+
}));
428+
// because we call the function again within 100ms
429+
p.push(Plotly.Plots.resize(gd));
430+
return Promise.all(p);
431+
})
432+
.catch(failTest)
433+
.then(done);
434+
});
435+
});
415436
});
416437

417438
describe('Plots.purge', function() {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy