Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit deb32ff

Browse filesBrowse files
committed
Plots.resize: reject old promises
1 parent 5ef8a61 commit deb32ff
Copy full SHA for deb32ff

File tree

Expand file treeCollapse file tree

2 files changed

+24
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+24
-0
lines changed

‎src/plots/plots.js

Copy file name to clipboardExpand all lines: src/plots/plots.js
+3Lines 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

Copy file name to clipboardExpand all lines: test/jasmine/tests/plots_test.js
+21Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.