fix(devtools): proper dev mode detection when app compiled with closure

This commit is contained in:
mgechev 2021-04-29 10:23:49 -07:00 committed by Minko Gechev
parent 8728f6f578
commit ee0c245b44
3 changed files with 16 additions and 3 deletions

View file

@ -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 => {

View file

@ -50,7 +50,7 @@ export const subscribeToClientEvents = (messageBus: MessageBus<Events>): 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))

View file

@ -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) => {