From 832711d4157ab75eebf7a26eaaac7913f8bf8d9a Mon Sep 17 00:00:00 2001 From: bekzod Date: Sat, 20 May 2017 21:18:31 +0500 Subject: [PATCH] made checks explicit --- lib/es6-promise/then.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/es6-promise/then.js b/lib/es6-promise/then.js index b2b79f0..cc74326 100644 --- a/lib/es6-promise/then.js +++ b/lib/es6-promise/then.js @@ -21,11 +21,11 @@ export default function then(onFulfillment, onRejection) { const { _state } = parent; - if (_state) { - const callback = arguments[_state - 1]; - asap(() => invokeCallback(_state, child, callback, parent._result)); - } else { + if (_state === PENDING) { subscribe(parent, child, onFulfillment, onRejection); + } else { + const callback = _state === FULFILLED ? onFulfillment : onRejection; + asap(() => invokeCallback(_state, child, callback, parent._result)); } return child;