We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cd43d12 commit 41a02edCopy full SHA for 41a02ed
packages/scheduler/src/queueMicrotask.js
@@ -6,20 +6,18 @@
6
*
7
*/
8
9
-function queueMicrotaskPolyfill(callback: boolean => void) {
10
- if (typeof queueMicrotask !== 'undefined') {
11
- queueMicrotask(callback);
12
- } else if (typeof Promise !== 'undefined') {
13
- Promise.resolve(null)
14
- .then(callback)
15
- .catch(e => {
16
- setTimeout(() => {
17
- throw e;
18
- });
19
20
- } else {
21
- setTimeout(callback);
22
- }
23
-}
+const queueMicrotaskImpl =
+ typeof queueMicrotask === 'function'
+ ? queueMicrotask
+ : typeof Promise !== 'undefined'
+ ? callback =>
+ Promise.resolve(null)
+ .then(callback)
+ .catch(e => {
+ setTimeout(() => {
+ throw e;
+ });
+ })
+ : setTimeout;
24
25
-export default queueMicrotaskPolyfill;
+export default queueMicrotaskImpl;
0 commit comments