File tree 2 files changed +18
-5
lines changed
2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ function downloadImage(gd, opts) {
40
40
// does not allow toDataURL
41
41
// svg format will work though
42
42
if ( Lib . isIE ( ) && opts . format !== 'svg' ) {
43
- reject ( new Error ( 'Sorry IE does not support downloading from canvas. Try {format:" svg" } instead.' ) ) ;
43
+ reject ( new Error ( 'Sorry IE does not support downloading from canvas. Try {format:\' svg\' } instead.' ) ) ;
44
44
}
45
45
46
46
gd . _snapshotInProgress = true ;
Original file line number Diff line number Diff line change @@ -21,10 +21,6 @@ function svgToImg(opts) {
21
21
22
22
var svg = opts . svg ;
23
23
var format = opts . format || 'png' ;
24
- var canvas = opts . canvas ;
25
-
26
- var ctx = canvas . getContext ( '2d' ) ;
27
- var img = new Image ( ) ;
28
24
29
25
// IE is very strict, so we will need to clean
30
26
// svg with the following regex
@@ -43,8 +39,25 @@ function svgToImg(opts) {
43
39
// font names with spaces will be escaped single-quoted
44
40
// we'll need to change these to double-quoted
45
41
svg = svg . replace ( / ( \\ ' ) / gi, '\"' ) ;
42
+ // IE only support svg
43
+ if ( format !== 'svg' ) {
44
+ var ieSvgError = new Error ( 'Sorry IE does not support downloading from canvas. Try {format:\'svg\'} instead.' ) ;
45
+ reject ( ieSvgError ) ;
46
+ // eventually remove the ev
47
+ // in favor of promises
48
+ if ( ! opts . promise ) {
49
+ return ev . emit ( 'error' , ieSvgError ) ;
50
+ } else {
51
+ return promise ;
52
+ }
53
+ }
46
54
}
47
55
56
+ var canvas = opts . canvas ;
57
+
58
+ var ctx = canvas . getContext ( '2d' ) ;
59
+ var img = new Image ( ) ;
60
+
48
61
// for Safari support, eliminate createObjectURL
49
62
// this decision could cause problems if content
50
63
// is not restricted to svg
You can’t perform that action at this time.
0 commit comments