Skip to content

Commit 524b44f

Browse files
authored
Merge pull request #1045 from tete1030/fix-domtoimage-uri
Fix dom-to-image: illegal symbols in data-uri, zero height svg
2 parents 48bdc61 + 2eea3a5 commit 524b44f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/js/dom-to-image.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// dom-to-image-2.6.0
2-
// patched to add toCanvas public function (line 111)
3-
// patched to fix uncaught in promise (line 741)
2+
// patched to add toCanvas public function (line 112)
3+
// patched to fix uncaught in promise (line 742)
4+
// patched to fix illegal symbols in data-uri (line 349, 358)
45
(function (global) {
56
'use strict';
67

@@ -345,7 +346,7 @@
345346
node.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
346347
return new XMLSerializer().serializeToString(node);
347348
})
348-
.then(util.escapeXhtml)
349+
// .then(util.escapeXhtml)
349350
.then(function (xhtml) {
350351
return '<foreignObject x="0" y="0" width="100%" height="100%">' + xhtml + '</foreignObject>';
351352
})
@@ -354,7 +355,7 @@
354355
foreignObject + '</svg>';
355356
})
356357
.then(function (svg) {
357-
return 'data:image/svg+xml;charset=utf-8,' + svg;
358+
return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
358359
});
359360
}
360361

src/js/gsTabSuspendManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ var gsTabSuspendManager = (function() {
560560
if (useAlternateScreenCaptureLib) {
561561
// console.log('Generating via dom-to-image..');
562562
generateCanvas = () => {
563-
return domtoimage.toCanvas(document.body, {}).then(canvas => {
563+
return domtoimage.toCanvas(document.body, {width: width, height: height}).then(canvas => {
564564
const croppedCanvas = document.createElement('canvas');
565565
const context = croppedCanvas.getContext('2d');
566566
croppedCanvas.width = width;

0 commit comments

Comments
 (0)