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

Unified Diff: src/promise.js

Issue 180723011: PromiseThen should ignore non-function parameters. (Closed) Base URL: git://github.com/v8/v8.git@master
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 | no next file » | 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 82aa99027a1305ac8bf6b95672cccd89504173cd..b3bae9efd7e4fe656bc1e5ea47d62f1bead1f9d4 100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -148,8 +148,9 @@ function PromiseIdResolveHandler(x) { return x }
function PromiseIdRejectHandler(r) { throw r }
function PromiseChain(onResolve, onReject) { // a.k.a. flatMap
- onResolve = IS_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve;
- onReject = IS_UNDEFINED(onReject) ? PromiseIdRejectHandler : onReject;
+ onResolve =
+ typeof onResolve === 'function' ? onResolve : PromiseIdResolveHandler;
rossberg 2014/04/28 08:32:52 We shouldn't change .chain, only .then
yhirano 2014/04/28 12:35:40 Done.
+ onReject = typeof onReject === 'function' ? onReject : PromiseIdRejectHandler;
var deferred = %_CallFunction(this.constructor, PromiseDeferred);
switch (GET_PRIVATE(this, promiseStatus)) {
case UNDEFINED:
@@ -201,7 +202,8 @@ function PromiseHandle(value, handler, deferred) {
// Multi-unwrapped chaining with thenable coercion.
function PromiseThen(onResolve, onReject) {
- onResolve = IS_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve;
+ onResolve =
+ typeof onResolve === 'function' ? onResolve : PromiseIdResolveHandler;
rossberg 2014/04/28 08:32:52 Please use the IS_SPEC_FUNCTION macro instead.
yhirano 2014/04/28 12:35:40 Done.
var that = this;
var constructor = this.constructor;
return this.chain(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698