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 { 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 }> {