|
301 | 301 | timeout: 0
|
302 | 302 | },
|
303 | 303 |
|
| 304 | + // jQuery versions before 1.8 require promise.pipe if the return value is |
| 305 | + // used, as promise.then in older versions has a different behavior, see: |
| 306 | + // https://blog.jquery.com/2012/08/09/jquery-1-8-released/ |
| 307 | + // https://bugs.jquery.com/ticket/11010 |
| 308 | + // https://github.com/blueimp/jQuery-File-Upload/pull/3435 |
| 309 | + _promisePipe: (function () { |
| 310 | + var parts = $.fn.jquery.split('.'); |
| 311 | + return Number(parts[0]) > 1 || Number(parts[1]) > 7 ? 'then' : 'pipe'; |
| 312 | + })(), |
| 313 | + |
304 | 314 | // A list of options that require reinitializing event listeners and/or
|
305 | 315 | // special initialization code:
|
306 | 316 | _specialOptions: [
|
|
732 | 742 | };
|
733 | 743 | data.process = function (resolveFunc, rejectFunc) {
|
734 | 744 | if (resolveFunc || rejectFunc) {
|
735 |
| - data._processQueue = this._processQueue = ( |
736 |
| - this._processQueue || getPromise([this]) |
737 |
| - ) |
738 |
| - .then(function () { |
| 745 | + data._processQueue = this._processQueue = (this._processQueue || |
| 746 | + getPromise([this])) |
| 747 | + [that._promisePipe](function () { |
739 | 748 | if (data.errorThrown) {
|
740 | 749 | return $.Deferred().rejectWith(that, [data]).promise();
|
741 | 750 | }
|
742 | 751 | return getPromise(arguments);
|
743 | 752 | })
|
744 |
| - .then(resolveFunc, rejectFunc); |
| 753 | + [that._promisePipe](resolveFunc, rejectFunc); |
745 | 754 | }
|
746 | 755 | return this._processQueue || getPromise([this]);
|
747 | 756 | };
|
|
1052 | 1061 | if (this.options.limitConcurrentUploads > 1) {
|
1053 | 1062 | slot = $.Deferred();
|
1054 | 1063 | this._slots.push(slot);
|
1055 |
| - pipe = slot.then(send); |
| 1064 | + pipe = slot[that._promisePipe](send); |
1056 | 1065 | } else {
|
1057 |
| - this._sequence = this._sequence.then(send, send); |
| 1066 | + this._sequence = this._sequence[that._promisePipe](send, send); |
1058 | 1067 | pipe = this._sequence;
|
1059 | 1068 | }
|
1060 | 1069 | // Return the piped Promise object, enhanced with an abort method,
|
|
1254 | 1263 | return that._handleFileTreeEntry(entry, path);
|
1255 | 1264 | })
|
1256 | 1265 | )
|
1257 |
| - .then(function () { |
| 1266 | + [this._promisePipe](function () { |
1258 | 1267 | return Array.prototype.concat.apply([], arguments);
|
1259 | 1268 | });
|
1260 | 1269 | },
|
|
1322 | 1331 | }
|
1323 | 1332 | return $.when
|
1324 | 1333 | .apply($, $.map(fileInput, this._getSingleFileInputFiles))
|
1325 |
| - .then(function () { |
| 1334 | + [this._promisePipe](function () { |
1326 | 1335 | return Array.prototype.concat.apply([], arguments);
|
1327 | 1336 | });
|
1328 | 1337 | },
|
|
0 commit comments