fix(dev-tools): use app root in getDocument() (#8071)

This commit is contained in:
Alexander Vakrilov
2019-11-08 11:14:29 +02:00
committed by Martin Yankov
parent 7fa997865b
commit f68647233f

View File

@ -4,6 +4,9 @@ import { getNodeById } from "./dom-node";
import { ViewBase } from "../ui/core/view-base"; import { ViewBase } from "../ui/core/view-base";
import { mainThreadify } from "../utils/utils"; import { mainThreadify } from "../utils/utils";
// Use lazy requires for core modules
const getAppRootView = () => require("../application").getRootView();
let unsetValue; let unsetValue;
function unsetViewValue(view, name) { function unsetViewValue(view, name) {
if (!unsetValue) { if (!unsetValue) {
@ -24,19 +27,19 @@ function getViewById(nodeId: number): ViewBase {
} }
export function getDocument() { export function getDocument() {
const topMostFrame = require("../ui/frame").Frame.topmost(); const appRoot = getAppRootView();
if (!topMostFrame) { if (!appRoot) {
return undefined; return undefined;
} }
try { try {
topMostFrame.ensureDomNode(); appRoot.ensureDomNode();
} catch (e) { } catch (e) {
console.log("ERROR in getDocument(): " + e); console.log("ERROR in getDocument(): " + e);
} }
return topMostFrame.domNode.toObject(); return appRoot.domNode.toObject();
} }
export function getComputedStylesForNode(nodeId): Array<{ name: string, value: string }> { export function getComputedStylesForNode(nodeId): Array<{ name: string, value: string }> {