Skip to content

Commit f5b3b56

Browse files
committed
Make sure the progress and response container objects are initialized.
1 parent 6ae7870 commit f5b3b56

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

js/jquery.fileupload.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload Plugin 5.28
2+
* jQuery File Upload Plugin 5.28.1
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -262,11 +262,29 @@
262262
},
263263

264264
_initProgressObject: function (obj) {
265-
obj._progress = {
265+
var progress = {
266266
loaded: 0,
267267
total: 0,
268268
bitrate: 0
269269
};
270+
if (obj._progress) {
271+
$.extend(obj._progress, progress);
272+
} else {
273+
obj._progress = progress;
274+
}
275+
},
276+
277+
_initResponseObject: function (obj) {
278+
var prop;
279+
if (obj._response) {
280+
for (prop in obj._response) {
281+
if (obj._response.hasOwnProperty(prop)) {
282+
delete obj._response[prop];
283+
}
284+
}
285+
} else {
286+
obj._response = {};
287+
}
270288
},
271289

272290
_onProgress: function (e, data) {
@@ -683,15 +701,10 @@
683701
this._progress.bitrate = 0;
684702
}
685703
// Make sure the container objects for the .response() and
686-
// .progress() methods on the data object are available.
687-
// They are set in the add callback, but files might have
688-
// been sent via send API call:
689-
if (!data._response) {
690-
data._response = {};
691-
}
692-
if (!data._progress) {
693-
data._progress = {};
694-
}
704+
// .progress() methods on the data object are available
705+
// and reset to their initial state:
706+
this._initResponseObject(data);
707+
this._initProgressObject(data);
695708
data._progress.loaded = data.loaded = data.uploadedBytes || 0;
696709
data._progress.total = data.total = this._getTotal(data.files) || 1;
697710
data._progress.bitrate = data.bitrate = 0;
@@ -853,7 +866,7 @@
853866
var newData = $.extend({}, data);
854867
newData.files = fileSet ? element : [element];
855868
newData.paramName = paramNameSet[index];
856-
newData._response = {};
869+
that._initResponseObject(newData);
857870
that._initProgressObject(newData);
858871
that._addConvenienceMethods(e, newData);
859872
result = that._trigger('add', e, newData);

0 commit comments

Comments
 (0)