Skip to content

Commit 49b6e47

Browse files
mikehuebnerimbalind
authored andcommitted
Fix For Windows 10 Exporter
This is a fix for the Windows 10 users. Instead of using `.match` we use `.search` which runs a boolean value. I noticed you guys were trying to get the exact version of IE and that isn’t going to work for Windows 10 users. I instead use the boolean value later to see if we are even in IE. the `navigator.msSaveBlob` is a function in IE 10+ and Edge so knowing that I can call that first and IE9 might possibly not blow up. I haven’t gotten to officially test IE9 yet. If anything, this PR is strictly a proof of concept. Feel free to message me with any questions!
1 parent 4189272 commit 49b6e47

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/features/exporter/js/exporter.js

100644100755
Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,14 @@
884884
* @description Checks whether current browser is IE and returns it's version if it is
885885
*/
886886
isIE: function () {
887-
var match = navigator.userAgent.match(/(?:MSIE |Trident\/.*; rv:)(\d+)/);
888-
return match ? parseInt(match[1]) : false;
887+
var match = navigator.userAgent.search(/(?:Edge|MSIE|Trident\/.*; rv:)/);
888+
var isIE = false;
889+
890+
if (match !== -1) {
891+
isIE = true;
892+
}
893+
894+
return isIE;
889895
},
890896

891897

@@ -1015,14 +1021,24 @@
10151021
var rawFile;
10161022
var ieVersion;
10171023

1018-
ieVersion = this.isIE();
1024+
ieVersion = this.isIE(); // This is now a boolean value
10191025
var doc = pdfMake.createPdf(docDefinition);
10201026
var blob;
10211027

10221028
doc.getBuffer( function (buffer) {
10231029
blob = new Blob([buffer]);
10241030

1025-
if (ieVersion && ieVersion < 10) {
1031+
// IE10+
1032+
if (navigator.msSaveBlob) {
1033+
return navigator.msSaveBlob(
1034+
blob, fileName
1035+
);
1036+
}
1037+
1038+
// Previously: && ieVersion < 10
1039+
// ieVersion now returns a boolean for the
1040+
// sake of sanity. We just check `msSaveBlob` first.
1041+
if (ieVersion) {
10261042
var frame = D.createElement('iframe');
10271043
document.body.appendChild(frame);
10281044

@@ -1035,13 +1051,6 @@
10351051
document.body.removeChild(frame);
10361052
return true;
10371053
}
1038-
1039-
// IE10+
1040-
if (navigator.msSaveBlob) {
1041-
return navigator.msSaveBlob(
1042-
blob, fileName
1043-
);
1044-
}
10451054
});
10461055
},
10471056

0 commit comments

Comments
 (0)