@builderx/bridge
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -202,3 +202,12 @@ "use strict"; | ||
function getDomNodeFromPath(path) { | ||
return document.querySelector(`[data-path="${path}"]`); | ||
const fiberNode = getFibreNodeFromPath(path); | ||
// Get the DOM node from the fiber node | ||
let domNode; | ||
if (fiberNode) { | ||
domNode = getDomNodeFromFiber(fiberNode); | ||
} | ||
else { | ||
domNode = document.querySelector(`[data-path="${path}"]`); | ||
} | ||
return domNode; | ||
} | ||
@@ -208,11 +217,3 @@ // Update this function | ||
const { layerId } = args; | ||
const fiberNode = getFibreNodeFromPath(layerId); | ||
// console.log(fiberNode, 'fiberNode in getLayerById initBridge') | ||
let element = null; | ||
if (fiberNode) { | ||
element = getDomNodeFromFiber(fiberNode); | ||
} | ||
else { | ||
element = getDomNodeFromPath(layerId); | ||
} | ||
const element = getDomNodeFromPath(layerId); | ||
if (element) { | ||
@@ -232,7 +233,4 @@ const rect = element.getBoundingClientRect(); | ||
const { layerId } = args; | ||
const fiberNode = getFibreNodeFromPath(layerId); | ||
console.log({ fiberNode }, 'fiberNode in getLayerComputedStyle initBridge'); | ||
// Get the DOM node from the fiber node | ||
const domNode = getDomNodeFromFiber(fiberNode); | ||
console.log({ domNode }, 'domNode in getLayerComputedStyle initBridge'); | ||
const domNode = getDomNodeFromPath(layerId); | ||
if (domNode) { | ||
@@ -239,0 +237,0 @@ // Get the computed style of the DOM node |
{ | ||
"name": "@builderx/bridge", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -130,3 +130,5 @@ declare global { | ||
case 'getLayerComputedStyle': | ||
result = getLayerComputedStyle(fnArgs); | ||
break; | ||
@@ -249,3 +251,12 @@ | ||
function getDomNodeFromPath(path: string): Element | null { | ||
return document.querySelector(`[data-path="${path}"]`); | ||
const fiberNode = getFibreNodeFromPath(path); | ||
// Get the DOM node from the fiber node | ||
let domNode: Element | null; | ||
if (fiberNode) { | ||
domNode = getDomNodeFromFiber(fiberNode); | ||
} else { | ||
domNode = document.querySelector(`[data-path="${path}"]`); | ||
} | ||
return domNode; | ||
} | ||
@@ -255,12 +266,4 @@ // Update this function | ||
const { layerId } = args; | ||
const element: Element | null = getDomNodeFromPath(layerId); | ||
const fiberNode = getFibreNodeFromPath(layerId); | ||
// console.log(fiberNode, 'fiberNode in getLayerById initBridge') | ||
let element: Element | null = null; | ||
if (fiberNode) { | ||
element = getDomNodeFromFiber(fiberNode); | ||
} else { | ||
element = getDomNodeFromPath(layerId); | ||
} | ||
if (element) { | ||
@@ -281,9 +284,8 @@ const rect = element.getBoundingClientRect(); | ||
function getLayerComputedStyle(args: { layerId: string }): any { | ||
const { layerId } = args; | ||
const fiberNode = getFibreNodeFromPath(layerId); | ||
console.log({fiberNode}, 'fiberNode in getLayerComputedStyle initBridge') | ||
// Get the DOM node from the fiber node | ||
const domNode = getDomNodeFromFiber(fiberNode); | ||
console.log({domNode}, 'domNode in getLayerComputedStyle initBridge') | ||
const domNode: any = getDomNodeFromPath(layerId); | ||
if (domNode) { | ||
@@ -290,0 +292,0 @@ // Get the computed style of the DOM node |
Sorry, the diff of this file is not supported yet
82325
1567