This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1251,14 +1251,20 @@ const Zone: ZoneType = (function(global: any) {
1251
1251
const symbolThen = __symbol__ ( 'then' ) ;
1252
1252
let _microTaskQueue : Task [ ] = [ ] ;
1253
1253
let _isDrainingMicrotaskQueue : boolean = false ;
1254
+ let nativeMicroTaskQueuePromise : any ;
1254
1255
1255
1256
function scheduleMicroTask ( task ?: MicroTask ) {
1256
1257
// if we are not running in any task, and there has not been anything scheduled
1257
1258
// we must bootstrap the initial task creation by manually scheduling the drain
1258
1259
if ( _numberOfNestedTaskFrames === 0 && _microTaskQueue . length === 0 ) {
1259
1260
// We are not running in Task, so we need to kickstart the microtask queue.
1260
- if ( global [ symbolPromise ] ) {
1261
- global [ symbolPromise ] . resolve ( 0 ) [ symbolThen ] ( drainMicroTaskQueue ) ;
1261
+ if ( ! nativeMicroTaskQueuePromise ) {
1262
+ if ( global [ symbolPromise ] ) {
1263
+ nativeMicroTaskQueuePromise = global [ symbolPromise ] . resolve ( 0 ) ;
1264
+ }
1265
+ }
1266
+ if ( nativeMicroTaskQueuePromise ) {
1267
+ nativeMicroTaskQueuePromise [ symbolThen ] ( drainMicroTaskQueue ) ;
1262
1268
} else {
1263
1269
global [ symbolSetTimeout ] ( drainMicroTaskQueue , 0 ) ;
1264
1270
}
You can’t perform that action at this time.
0 commit comments