Skip to content

Commit

Permalink
Merge pull request #1045 from tete1030/fix-domtoimage-uri
Browse files Browse the repository at this point in the history
Fix dom-to-image: illegal symbols in data-uri, zero height svg
  • Loading branch information
deanoemcke authored May 23, 2020
2 parents 48bdc61 + 2eea3a5 commit 524b44f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/js/dom-to-image.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// dom-to-image-2.6.0
// patched to add toCanvas public function (line 111)
// patched to fix uncaught in promise (line 741)
// patched to add toCanvas public function (line 112)
// patched to fix uncaught in promise (line 742)
// patched to fix illegal symbols in data-uri (line 349, 358)
(function (global) {
'use strict';

Expand Down Expand Up @@ -345,7 +346,7 @@
node.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
return new XMLSerializer().serializeToString(node);
})
.then(util.escapeXhtml)
// .then(util.escapeXhtml)
.then(function (xhtml) {
return '<foreignObject x="0" y="0" width="100%" height="100%">' + xhtml + '</foreignObject>';
})
Expand All @@ -354,7 +355,7 @@
foreignObject + '</svg>';
})
.then(function (svg) {
return 'data:image/svg+xml;charset=utf-8,' + svg;
return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/js/gsTabSuspendManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ var gsTabSuspendManager = (function() {
if (useAlternateScreenCaptureLib) {
// console.log('Generating via dom-to-image..');
generateCanvas = () => {
return domtoimage.toCanvas(document.body, {}).then(canvas => {
return domtoimage.toCanvas(document.body, {width: width, height: height}).then(canvas => {
const croppedCanvas = document.createElement('canvas');
const context = croppedCanvas.getContext('2d');
croppedCanvas.width = width;
Expand Down

0 comments on commit 524b44f

Please sign in to comment.