Commit ebd6fe80 authored by Tristan Cavelier's avatar Tristan Cavelier

Promise improving propagation

parent 426f2a71
...@@ -465,16 +465,20 @@ Promise.prototype.then = function (onSuccess, onError, onProgress) { ...@@ -465,16 +465,20 @@ Promise.prototype.then = function (onSuccess, onError, onProgress) {
}); });
} else { } else {
setTimeout(function () { setTimeout(function () {
resolver.resolve(); resolver.resolve.apply(resolver, that._answers);
}); });
} }
break; break;
case "rejected": case "rejected":
if (typeof onError === 'function') { if (typeof onError === 'function') {
setTimeout(function () { setTimeout(function () {
var result = onError.apply(that, that._answers);
// try { // try {
if (result === undefined) {
return resolver.reject.apply(resolver, that._answers);
}
Promise.when( Promise.when(
onError.apply(that, that._answers), result,
resolver.reject, resolver.reject,
resolver.reject resolver.reject
); );
...@@ -504,7 +508,7 @@ Promise.prototype.then = function (onSuccess, onError, onProgress) { ...@@ -504,7 +508,7 @@ Promise.prototype.then = function (onSuccess, onError, onProgress) {
}); });
} else { } else {
this._onResolve.push(function () { this._onResolve.push(function () {
resolver.resolve(); resolver.resolve.apply(resolver, arguments);
}); });
} }
if (typeof onError === 'function') { if (typeof onError === 'function') {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment