File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 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) {
4040 // does not allow toDataURL
4141 // svg format will work though
4242 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.' ) ) ;
4444 }
4545
4646 gd . _snapshotInProgress = true ;
Original file line number Diff line number Diff line change @@ -21,10 +21,6 @@ function svgToImg(opts) {
2121
2222 var svg = opts . svg ;
2323 var format = opts . format || 'png' ;
24- var canvas = opts . canvas ;
25-
26- var ctx = canvas . getContext ( '2d' ) ;
27- var img = new Image ( ) ;
2824
2925 // IE is very strict, so we will need to clean
3026 // svg with the following regex
@@ -43,8 +39,25 @@ function svgToImg(opts) {
4339 // font names with spaces will be escaped single-quoted
4440 // we'll need to change these to double-quoted
4541 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+ }
4654 }
4755
56+ var canvas = opts . canvas ;
57+
58+ var ctx = canvas . getContext ( '2d' ) ;
59+ var img = new Image ( ) ;
60+
4861 // for Safari support, eliminate createObjectURL
4962 // this decision could cause problems if content
5063 // is not restricted to svg
You can’t perform that action at this time.
0 commit comments