This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1251,14 +1251,20 @@ const Zone: ZoneType = (function(global: any) {
12511251 const symbolThen = __symbol__ ( 'then' ) ;
12521252 let _microTaskQueue : Task [ ] = [ ] ;
12531253 let _isDrainingMicrotaskQueue : boolean = false ;
1254+ let nativeMicroTaskQueuePromise : any ;
12541255
12551256 function scheduleMicroTask ( task ?: MicroTask ) {
12561257 // if we are not running in any task, and there has not been anything scheduled
12571258 // we must bootstrap the initial task creation by manually scheduling the drain
12581259 if ( _numberOfNestedTaskFrames === 0 && _microTaskQueue . length === 0 ) {
12591260 // 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 ) ;
12621268 } else {
12631269 global [ symbolSetTimeout ] ( drainMicroTaskQueue , 0 ) ;
12641270 }
You can’t perform that action at this time.
0 commit comments