diff --git a/projects/ng-devtools-backend/src/lib/angular-check.ts b/projects/ng-devtools-backend/src/lib/angular-check.ts index 9fdc078cd59..58febdad5a9 100644 --- a/projects/ng-devtools-backend/src/lib/angular-check.ts +++ b/projects/ng-devtools-backend/src/lib/angular-check.ts @@ -21,8 +21,16 @@ export const appIsSupportedAngularVersion = (): boolean => { return appIsAngular() && (major >= 9 || major === 0); }; +/** + * We check if the global `window.ng` is an object and if this object + * has the `getComponent` method attached to it. In some g3 apps processed + * with Closure, `ng` is a function, which means that `typeof ng !== 'undefined'` + * is not a sufficient check. + * + * @returns if the app has global ng debug object + */ const appHasGlobalNgDebugObject = (): boolean => { - return typeof ng !== 'undefined'; + return typeof ng === 'object' && typeof ng.getComponent === 'function'; }; export const getAngularVersion = (): string | null => { diff --git a/projects/ng-devtools-backend/src/lib/client-event-subscribers.ts b/projects/ng-devtools-backend/src/lib/client-event-subscribers.ts index d7755aecaf7..4bb56802c08 100644 --- a/projects/ng-devtools-backend/src/lib/client-event-subscribers.ts +++ b/projects/ng-devtools-backend/src/lib/client-event-subscribers.ts @@ -50,7 +50,7 @@ export const subscribeToClientEvents = (messageBus: MessageBus): void => // Often websites have `scroll` event listener which triggers // Angular's change detection. We don't want to constantly send // update requests, instead we want to request an update at most - // every 250ms + // once every 250ms runOutsideAngular(() => { initializeOrGetDirectiveForestHooks() .profiler.changeDetection$.pipe(debounceTime(250)) diff --git a/projects/ng-devtools-backend/src/lib/utils.ts b/projects/ng-devtools-backend/src/lib/utils.ts index 9d1e77e4fb0..7b0724b2087 100644 --- a/projects/ng-devtools-backend/src/lib/utils.ts +++ b/projects/ng-devtools-backend/src/lib/utils.ts @@ -8,7 +8,12 @@ export const runOutsideAngular = (f: () => any): void => { w.Zone.current.run(f); return; } - w.Zone.current._parent.run(f); + const parent = w.Zone.current._parent; + if (parent && parent.run) { + parent.run(f); + return; + } + f(); }; export const isCustomElement = (node: Node) => {