Index: src/promise.js |
diff --git a/src/promise.js b/src/promise.js |
index fa650eaf0e983d31d988dc7093d11398ea515091..f4c60d66cacc9538b8aa7d7133481251b3833b0e 100644 |
--- a/src/promise.js |
+++ b/src/promise.js |
@@ -204,31 +204,22 @@ function PromiseThen(onResolve, onReject) { |
); |
} |
-PromiseCoerce.table = new $WeakMap; |
- |
function PromiseCoerce(constructor, x) { |
if (!IsPromise(x) && IS_SPEC_OBJECT(x)) { |
var then; |
try { |
then = x.then; |
} catch(r) { |
- var promise = %_CallFunction(constructor, r, PromiseRejected); |
- PromiseCoerce.table.set(x, promise); |
- return promise; |
+ return %_CallFunction(constructor, r, PromiseRejected); |
} |
- if (typeof then === 'function') { |
- if (PromiseCoerce.table.has(x)) { |
- return PromiseCoerce.table.get(x); |
- } else { |
- var deferred = %_CallFunction(constructor, PromiseDeferred); |
- PromiseCoerce.table.set(x, deferred.promise); |
- try { |
- %_CallFunction(x, deferred.resolve, deferred.reject, then); |
- } catch(r) { |
- deferred.reject(r); |
- } |
- return deferred.promise; |
+ if (IS_SPEC_FUNCTION(then)) { |
+ var deferred = %_CallFunction(constructor, PromiseDeferred); |
+ try { |
+ %_CallFunction(x, deferred.resolve, deferred.reject, then); |
+ } catch(r) { |
+ deferred.reject(r); |
} |
+ return deferred.promise; |
} |
} |
return x; |