mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
fix(dev-tools): use app root in getDocument() (#8071)
This commit is contained in:

committed by
Martin Yankov

parent
7fa997865b
commit
f68647233f
@ -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 }> {
|
||||||
|
Reference in New Issue
Block a user