Skip to content

Commit 94bfcdd

Browse files
crisbetoAndrewKushnir
authored andcommitted
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
1 parent f0a8303 commit 94bfcdd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/core/src/zone/ng_zone.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ export class NgZone {
153153
}
154154

155155
static isInAngularZone(): boolean {
156-
return Zone.current.get('isAngularZone') === true;
156+
// Zone needs to be checked, because this method might be called even when NoopNgZone is used.
157+
return typeof Zone !== 'undefined' && Zone.current.get('isAngularZone') === true;
157158
}
158159

159160
static assertInAngularZone(): void {

0 commit comments

Comments
 (0)