fix(testing): ComponentFixture - Avoid extra scheduleMicrotask (#10223)
Don't schedule microtask to check for pending macrotasks when no one is waiting for a whenStable().
This commit is contained in:
parent
190bcc89c1
commit
e34eb4520f
@ -87,16 +87,20 @@ export class ComponentFixture<T> {
|
|||||||
});
|
});
|
||||||
this._onStableSubscription = ObservableWrapper.subscribe(ngZone.onStable, (_) => {
|
this._onStableSubscription = ObservableWrapper.subscribe(ngZone.onStable, (_) => {
|
||||||
this._isStable = true;
|
this._isStable = true;
|
||||||
// Check whether there are no pending macrotasks in a microtask so that ngZone gets a chance
|
// Check whether there is a pending whenStable() completer to resolve.
|
||||||
// to update the state of pending macrotasks.
|
if (this._completer !== null) {
|
||||||
|
// If so check whether there are no pending macrotasks before resolving.
|
||||||
|
// Do this check in the next tick so that ngZone gets a chance to update the state of
|
||||||
|
// pending macrotasks.
|
||||||
scheduleMicroTask(() => {
|
scheduleMicroTask(() => {
|
||||||
if (!this.ngZone.hasPendingMacrotasks) {
|
if (!this.ngZone.hasPendingMacrotasks) {
|
||||||
if (this._completer != null) {
|
if (this._completer !== null) {
|
||||||
this._completer.resolve(true);
|
this._completer.resolve(true);
|
||||||
this._completer = null;
|
this._completer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this._onErrorSubscription = ObservableWrapper.subscribe(
|
this._onErrorSubscription = ObservableWrapper.subscribe(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user