Skip to content

Commit 648ff96

Browse files
authored
Use FileReader in macOS native apps using WebKit (#613)
Use FileReader in macOS native apps using WebKit
2 parents 480d547 + 7a8ff3c commit 648ff96

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

dist/FileSaver.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@
8383
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
8484
node.dispatchEvent(evt);
8585
}
86-
}
86+
} // Detect WebKit inside a native macOS app
87+
8788

89+
var isWebKit = /AppleWebKit/.test(navigator.userAgent);
8890
var saveAs = _global.saveAs || ( // probably in some web worker
8991
typeof window !== 'object' || window !== _global ? function saveAs() {}
9092
/* noop */
91-
// Use download attribute first if possible (#193 Lumia mobile)
92-
: 'download' in HTMLAnchorElement.prototype ? function saveAs(blob, name, opts) {
93+
// Use download attribute first if possible (#193 Lumia mobile) unless this is a native macOS app
94+
: 'download' in HTMLAnchorElement.prototype && !isWebKit ? function saveAs(blob, name, opts) {
9395
var URL = _global.URL || _global.webkitURL;
9496
var a = document.createElement('a');
9597
name = name || blob.name || 'download';
@@ -153,7 +155,7 @@
153155

154156
var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
155157

156-
if ((isChromeIOS || force && isSafari) && typeof FileReader !== 'undefined') {
158+
if ((isChromeIOS || force && isSafari || isWebKit) && typeof FileReader !== 'undefined') {
157159
// Safari doesn't allow downloading of blob URLs
158160
var reader = new FileReader();
159161

dist/FileSaver.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)