File tree 2 files changed +11
-2
lines changed
platform-browser/animations/src
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'unde
21
21
self instanceof WorkerGlobalScope && self ;
22
22
const __global = typeof global !== 'undefined' && global ;
23
23
const _global : { [ name : string ] : any } = __window || __global || __self ;
24
+
25
+ const promise : Promise < any > = Promise . resolve ( 0 ) ;
24
26
/**
25
27
* Attention: whenever providing a new value, be sure to add an
26
28
* entry into the corresponding `....externs.js` file,
@@ -52,7 +54,12 @@ export function getSymbolIterator(): string|symbol {
52
54
}
53
55
54
56
export function scheduleMicroTask ( fn : Function ) {
55
- Zone . current . scheduleMicroTask ( 'scheduleMicrotask' , fn ) ;
57
+ if ( typeof Zone === 'undefined' ) {
58
+ // use promise to schedule microTask instead of use Zone
59
+ promise . then ( ( ) => { fn && fn . apply ( null , null ) ; } ) ;
60
+ } else {
61
+ Zone . current . scheduleMicroTask ( 'scheduleMicrotask' , fn ) ;
62
+ }
56
63
}
57
64
58
65
// JS has NaN !== NaN
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export class AnimationRendererFactory implements RendererFactory2 {
19
19
private _animationCallbacksBuffer : [ ( e : any ) => any , any ] [ ] = [ ] ;
20
20
private _rendererCache = new Map < Renderer2 , BaseAnimationRenderer > ( ) ;
21
21
private _cdRecurDepth = 0 ;
22
+ private promise : Promise < any > = Promise . resolve ( 0 ) ;
22
23
23
24
constructor (
24
25
private delegate : RendererFactory2 , private engine : AnimationEngine , private _zone : NgZone ) {
@@ -69,7 +70,8 @@ export class AnimationRendererFactory implements RendererFactory2 {
69
70
}
70
71
71
72
private _scheduleCountTask ( ) {
72
- Zone . current . scheduleMicroTask ( 'incremenet the animation microtask' , ( ) => this . _microtaskId ++ ) ;
73
+ // always use promise to schedule microtask instead of use Zone
74
+ this . promise . then ( ( ) => { this . _microtaskId ++ ; } ) ;
73
75
}
74
76
75
77
/* @internal */
You can’t perform that action at this time.
0 commit comments