Skip to content

Commit aae88bb

Browse files
author
Philipp Alferov
committed
Update FileSaver.js
1 parent 74382ec commit aae88bb

File tree

4 files changed

+49
-29
lines changed

4 files changed

+49
-29
lines changed

dist/angular-file-saver.bundle.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ return /******/ (function(modules) { // webpackBootstrap
393393

394394
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* FileSaver.js
395395
* A saveAs() FileSaver implementation.
396-
* 1.1.20151003
396+
* 1.1.20160328
397397
*
398398
* By Eli Grey, http://eligrey.com
399399
* License: MIT
@@ -433,10 +433,8 @@ return /******/ (function(modules) { // webpackBootstrap
433433
}
434434
, force_saveable_type = "application/octet-stream"
435435
, fs_min_size = 0
436-
// See https://code.google.com/p/chromium/issues/detail?id=375297#c7 and
437-
// https://github.com/eligrey/FileSaver.js/commit/485930a#commitcomment-8768047
438-
// for the reasoning behind the timeout and revocation flow
439-
, arbitrary_revoke_timeout = 500 // in ms
436+
// the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to
437+
, arbitrary_revoke_timeout = 1000 * 40 // in ms
440438
, revoke = function(file) {
441439
var revoker = function() {
442440
if (typeof file === "string") { // file is an object URL
@@ -445,11 +443,23 @@ return /******/ (function(modules) { // webpackBootstrap
445443
file.remove();
446444
}
447445
};
448-
if (view.chrome) {
449-
revoker();
450-
} else {
451-
setTimeout(revoker, arbitrary_revoke_timeout);
446+
/* // Take note W3C:
447+
var
448+
uri = typeof file === "string" ? file : file.toURL()
449+
, revoker = function(evt) {
450+
// idealy DownloadFinishedEvent.data would be the URL requested
451+
if (evt.data === uri) {
452+
if (typeof file === "string") { // file is an object URL
453+
get_URL().revokeObjectURL(file);
454+
} else { // file is a File
455+
file.remove();
456+
}
457+
}
452458
}
459+
;
460+
view.addEventListener("downloadfinished", revoker);
461+
*/
462+
setTimeout(revoker, arbitrary_revoke_timeout);
453463
}
454464
, dispatch = function(filesaver, event_types, event) {
455465
event_types = [].concat(event_types);
@@ -509,7 +519,7 @@ return /******/ (function(modules) { // webpackBootstrap
509519
target_view.location.href = object_url;
510520
} else {
511521
var new_tab = view.open(object_url, "_blank");
512-
if (new_tab == undefined && is_safari) {
522+
if (new_tab === undefined && is_safari) {
513523
//Apple do not allow window.open, see http://bit.ly/1kZffRI
514524
view.location.href = object_url
515525
}
@@ -534,9 +544,9 @@ return /******/ (function(modules) { // webpackBootstrap
534544
}
535545
if (can_use_save_link) {
536546
object_url = get_URL().createObjectURL(blob);
537-
save_link.href = object_url;
538-
save_link.download = name;
539547
setTimeout(function() {
548+
save_link.href = object_url;
549+
save_link.download = name;
540550
click(save_link);
541551
dispatch_all();
542552
revoke(object_url);
@@ -656,7 +666,7 @@ return /******/ (function(modules) { // webpackBootstrap
656666

657667
if (typeof module !== "undefined" && module.exports) {
658668
module.exports.saveAs = saveAs;
659-
} else if (("function" !== "undefined" && __webpack_require__(7) !== null) && (__webpack_require__(8) != null)) {
669+
} else if (("function" !== "undefined" && __webpack_require__(7) !== null) && (__webpack_require__(8) !== null)) {
660670
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
661671
return saveAs;
662672
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));

dist/angular-file-saver.bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)