mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Cache local reference to global Promise (#21886)
This commit is contained in:
+4
-2
@@ -392,6 +392,7 @@ export const scheduleTimeout: any =
|
||||
export const cancelTimeout: any =
|
||||
typeof clearTimeout === 'function' ? clearTimeout : (undefined: any);
|
||||
export const noTimeout = -1;
|
||||
const localPromise = Promise;
|
||||
|
||||
// -------------------
|
||||
// Microtasks
|
||||
@@ -400,9 +401,10 @@ export const supportsMicrotasks = true;
|
||||
export const scheduleMicrotask: any =
|
||||
typeof queueMicrotask === 'function'
|
||||
? queueMicrotask
|
||||
: typeof Promise !== 'undefined'
|
||||
: typeof localPromise !== 'undefined'
|
||||
? callback =>
|
||||
Promise.resolve(null)
|
||||
localPromise
|
||||
.resolve(null)
|
||||
.then(callback)
|
||||
.catch(handleErrorInNextTick)
|
||||
: scheduleTimeout; // TODO: Determine the best fallback here.
|
||||
|
||||
Reference in New Issue
Block a user