Commit 47b35e23 authored by Stefan Penner's avatar Stefan Penner

simplify handling the thenable.

Removed the double try/catch
parent 253666b1
......@@ -131,16 +131,11 @@ function resolve(promise, value) {
function handleThenable(promise, value) {
var then = null;
if (objectOrFunction(value)) {
try {
if (objectOrFunction(value)) {
then = value.then;
} catch(e) {
reject(promise, e);
return true;
}
if (isFunction(then)) {
try {
then.call(value, function(val) {
if (value !== val) {
resolve(promise, val);
......@@ -150,12 +145,14 @@ function handleThenable(promise, value) {
}, function(val) {
reject(promise, val);
});
} catch (e) {
reject(promise, e);
}
return true;
}
}
} catch (error) {
reject(promise, error);
return true;
}
return false;
}
......
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