Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/plot_api/to_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ function toImage(gd, opts) {
setTimeout(function() {
var svg = Snapshot.toSVG(clonedGd);

var canvasContainer = window.document.createElement('div');
var canvas = window.document.createElement('canvas');
var canvasContainer = document.createElement('div'),
canvas = document.createElement('canvas');

canvasContainer.appendChild(canvas);
// no need to attach canvas container to DOM
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably can ⚡ the comment.

Also, do we even the canvasContainer? Can't we just use the canvas element directly? Not 🚫 but it's always nice to remove code.


canvasContainer.appendChild(canvas);
canvasContainer.id = Plotly.Lib.randstr();
canvas.id = Plotly.Lib.randstr();

Expand All @@ -86,6 +87,7 @@ function toImage(gd, opts) {
}).catch(function(err) {
reject(err);
});

}, delay);
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/snapshot/toimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ function toImage(gd, opts) {
setTimeout(function() {
var svg = Plotly.Snapshot.toSVG(clonedGd);

var canvasContainer = window.document.createElement('div');
var canvas = window.document.createElement('canvas');
var canvasContainer = document.createElement('div'),
canvas = document.createElement('canvas');

// window.document.body.appendChild(canvasContainer);
canvasContainer.appendChild(canvas);
// no need to attach canvas container to DOM
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


canvasContainer.appendChild(canvas);
canvasContainer.id = Plotly.Lib.randstr();
canvas.id = Plotly.Lib.randstr();

Expand Down