diff --git "a/8. \345\274\202\346\255\245\345\244\204\347\220\206/8-6. [\346\211\251\345\261\225]\346\211\213\345\206\231Promise/MyPromise.js" "b/8. \345\274\202\346\255\245\345\244\204\347\220\206/8-6. [\346\211\251\345\261\225]\346\211\213\345\206\231Promise/MyPromise.js" index f60ead1dabd6937517373b2327ea64076b4dde2d..9955d97c6cfdb7a7169f27def3f1bfb76ba8aff3 100644 --- "a/8. \345\274\202\346\255\245\345\244\204\347\220\206/8-6. [\346\211\251\345\261\225]\346\211\213\345\206\231Promise/MyPromise.js" +++ "b/8. \345\274\202\346\255\245\345\244\204\347\220\206/8-6. [\346\211\251\345\261\225]\346\211\213\345\206\231Promise/MyPromise.js" @@ -161,6 +161,12 @@ class MyPromise { // 目前状态已经更改 return; } + if (isPromise(value)) { + runMicroTask(() => { + value.then(this._resolve.bind(this), this._reject.bind(this)); + }); + return; + } this._state = newState; this._value = value; this._runHandlers(); // 状态变化,执行队列 @@ -285,4 +291,4 @@ class MyPromise { }); } } - +