Skip to content

Commit e855521

Browse files
committed
snapshot: clean wait callback
- rm unnecessary 'window' - rm commented out line (ne need to attach canvas to window)
1 parent d3b3513 commit e855521

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/plot_api/to_image.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ function toImage(gd, opts) {
6161
setTimeout(function() {
6262
var svg = Snapshot.toSVG(clonedGd);
6363

64-
var canvasContainer = window.document.createElement('div');
65-
var canvas = window.document.createElement('canvas');
64+
var canvasContainer = document.createElement('div'),
65+
canvas = document.createElement('canvas');
6666

67-
canvasContainer.appendChild(canvas);
67+
// no need to attach canvas container to DOM
6868

69+
canvasContainer.appendChild(canvas);
6970
canvasContainer.id = Plotly.Lib.randstr();
7071
canvas.id = Plotly.Lib.randstr();
7172

@@ -86,6 +87,7 @@ function toImage(gd, opts) {
8687
}).catch(function(err) {
8788
reject(err);
8889
});
90+
8991
}, delay);
9092
});
9193
}

src/snapshot/toimage.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ function toImage(gd, opts) {
3838
setTimeout(function() {
3939
var svg = Plotly.Snapshot.toSVG(clonedGd);
4040

41-
var canvasContainer = window.document.createElement('div');
42-
var canvas = window.document.createElement('canvas');
41+
var canvasContainer = document.createElement('div'),
42+
canvas = document.createElement('canvas');
4343

44-
// window.document.body.appendChild(canvasContainer);
45-
canvasContainer.appendChild(canvas);
44+
// no need to attach canvas container to DOM
4645

46+
canvasContainer.appendChild(canvas);
4747
canvasContainer.id = Plotly.Lib.randstr();
4848
canvas.id = Plotly.Lib.randstr();
4949

0 commit comments

Comments
 (0)