Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(982)

Unified Diff: src/promise.js

Issue 203453002: Promises: make null a legal argument for .then (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/es6/promises.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/promise.js
diff --git a/src/promise.js b/src/promise.js
index f700be909264cee92f077d60c5f331613ae86aed..f6b7bdff4b29a7af90b3d2ce21bd2712f3752e59 100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -210,7 +210,10 @@ function PromiseHandle(value, handler, deferred) {
// Multi-unwrapped chaining with thenable coercion.
function PromiseThen(onResolve, onReject) {
- onResolve = IS_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve;
+ onResolve =
+ IS_NULL_OR_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve;
+ onReject =
+ IS_NULL_OR_UNDEFINED(onReject) ? PromiseIdRejectHandler : onReject;
var that = this;
var constructor = this.constructor;
return this.chain(
@@ -230,11 +233,10 @@ function PromiseCoerce(constructor, x) {
var then;
try {
then = x.then;
- } catch(e) {
- var deferred = %_CallFunction(constructor, PromiseDeferred);
- PromiseCoerce.table.set(x, deferred.promise);
- deferred.reject(e);
- return deferred.promise;
+ } catch(r) {
Sven Panne 2014/03/18 14:46:18 Let me guess why you changed this... :-D
rossberg 2014/03/18 14:48:20 Reg-exps are the null pointers of parsing....
+ var promise = %_CallFunction(constructor, r, PromiseRejected);
+ PromiseCoerce.table.set(x, promise);
+ return promise;
}
if (typeof then === 'function') {
if (PromiseCoerce.table.has(x)) {
@@ -244,8 +246,8 @@ function PromiseCoerce(constructor, x) {
PromiseCoerce.table.set(x, deferred.promise);
try {
%_CallFunction(x, deferred.resolve, deferred.reject, then);
- } catch(e) {
- deferred.reject(e);
+ } catch(r) {
+ deferred.reject(r);
}
return deferred.promise;
}
« no previous file with comments | « no previous file | test/mjsunit/es6/promises.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698