Skip to content

Commit 753ef0e

Browse files
try to avoid objectURL to get Safari to work
1 parent 8a1aaba commit 753ef0e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/snapshot/svgtoimg.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,15 @@ function svgToImg(opts) {
2525

2626
var ctx = canvas.getContext('2d');
2727
var img = new Image();
28-
var DOMURL = window.URL || window.webkitURL;
29-
var svgBlob = new Blob([svg], {type: 'image/svg+xml;charset=utf-8'});
30-
var url = DOMURL.createObjectURL(svgBlob);
28+
29+
var base64Svg = 'data:image/svg+xml,' + encodeURIComponent(svg);
3130

3231
canvas.height = opts.height || 150;
3332
canvas.width = opts.width || 300;
3433

3534
img.onload = function() {
3635
var imgData;
3736

38-
DOMURL.revokeObjectURL(url);
3937
ctx.drawImage(img, 0, 0);
4038

4139
switch(format) {
@@ -68,7 +66,6 @@ function svgToImg(opts) {
6866
};
6967

7068
img.onerror = function(err) {
71-
DOMURL.revokeObjectURL(url);
7269
reject(err);
7370
// eventually remove the ev
7471
// in favor of promises

0 commit comments

Comments
 (0)