fix(core): error if NgZone.isInAngularZone is called with a noop zone (#44800)

When the user opts into the noop `NgZone`, they usually still interact with the static methods on the non-noop class. This change adds a check to handle the case where zone.js hasn't been loaded.

Fixes #44784.

PR Close #44800
This commit is contained in:
Kristiyan Kostadinov 2022-01-24 10:25:12 +01:00 committed by Andrew Kushnir
parent 8363db4189
commit 215db7fbe6

View file

@ -153,7 +153,8 @@ export class NgZone {
}
static isInAngularZone(): boolean {
return Zone.current.get('isAngularZone') === true;
// Zone needs to be checked, because this method might be called even when NoopNgZone is used.
return typeof Zone !== 'undefined' && Zone.current.get('isAngularZone') === true;
}
static assertInAngularZone(): void {