Skip to content

Commit 2a07984

Browse files
committed
Ensure the same state for the done, fail and always events.
1 parent f5b3b56 commit 2a07984

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

js/jquery.fileupload.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload Plugin 5.28.1
2+
* jQuery File Upload Plugin 5.28.2
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -734,28 +734,22 @@
734734

735735
_onFail: function (jqXHR, textStatus, errorThrown, options) {
736736
var response = options._response;
737-
response.jqXHR = options.jqXHR = jqXHR;
738-
response.textStatus = options.textStatus = textStatus;
739-
response.errorThrown = options.errorThrown = errorThrown;
740-
this._trigger('fail', null, options);
741737
if (options.recalculateProgress) {
742738
// Remove the failed (error or abort) file upload from
743739
// the global progress calculation:
744740
this._progress.loaded -= options._progress.loaded;
745741
this._progress.total -= options._progress.total;
746742
}
743+
response.jqXHR = options.jqXHR = jqXHR;
744+
response.textStatus = options.textStatus = textStatus;
745+
response.errorThrown = options.errorThrown = errorThrown;
746+
this._trigger('fail', null, options);
747747
},
748748

749749
_onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) {
750750
// jqXHRorResult, textStatus and jqXHRorError are added to the
751751
// options object via done and fail callbacks
752-
this._active -= 1;
753752
this._trigger('always', null, options);
754-
if (this._active === 0) {
755-
// The stop callback is triggered when all uploads have
756-
// been completed, equivalent to the global ajaxStop event:
757-
this._trigger('stop');
758-
}
759753
},
760754

761755
_onSend: function (e, data) {
@@ -781,13 +775,14 @@
781775
}).fail(function (jqXHR, textStatus, errorThrown) {
782776
that._onFail(jqXHR, textStatus, errorThrown, options);
783777
}).always(function (jqXHRorResult, textStatus, jqXHRorError) {
784-
that._sending -= 1;
785778
that._onAlways(
786779
jqXHRorResult,
787780
textStatus,
788781
jqXHRorError,
789782
options
790783
);
784+
that._sending -= 1;
785+
that._active -= 1;
791786
if (options.limitConcurrentUploads &&
792787
options.limitConcurrentUploads > that._sending) {
793788
// Start the next queued upload,
@@ -801,6 +796,11 @@
801796
nextSlot = that._slots.shift();
802797
}
803798
}
799+
if (that._active === 0) {
800+
// The stop callback is triggered when all uploads have
801+
// been completed, equivalent to the global ajaxStop event:
802+
that._trigger('stop');
803+
}
804804
});
805805
return jqXHR;
806806
};

0 commit comments

Comments
 (0)