From f68647233f5d05d0774c513539c16f42ec12ef21 Mon Sep 17 00:00:00 2001 From: Alexander Vakrilov Date: Fri, 8 Nov 2019 11:14:29 +0200 Subject: [PATCH] fix(dev-tools): use app root in getDocument() (#8071) --- .../debugger/devtools-elements.common.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nativescript-core/debugger/devtools-elements.common.ts b/nativescript-core/debugger/devtools-elements.common.ts index 5abfb667d..71473ef5a 100644 --- a/nativescript-core/debugger/devtools-elements.common.ts +++ b/nativescript-core/debugger/devtools-elements.common.ts @@ -4,6 +4,9 @@ import { getNodeById } from "./dom-node"; import { ViewBase } from "../ui/core/view-base"; import { mainThreadify } from "../utils/utils"; +// Use lazy requires for core modules +const getAppRootView = () => require("../application").getRootView(); + let unsetValue; function unsetViewValue(view, name) { if (!unsetValue) { @@ -24,19 +27,19 @@ function getViewById(nodeId: number): ViewBase { } export function getDocument() { - const topMostFrame = require("../ui/frame").Frame.topmost(); - if (!topMostFrame) { + const appRoot = getAppRootView(); + if (!appRoot) { return undefined; } try { - topMostFrame.ensureDomNode(); + appRoot.ensureDomNode(); } catch (e) { console.log("ERROR in getDocument(): " + e); } - return topMostFrame.domNode.toObject(); + return appRoot.domNode.toObject(); } export function getComputedStylesForNode(nodeId): Array<{ name: string, value: string }> {