UNPKG

react-dev-inspector

Version:

dev-tool for inspect react components and jump to local IDE for component code.

27 lines (26 loc) 1.39 kB
/** * mirror from https://github.com/facebook/react/blob/v16.13.1/packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js * * remove all process for iframe, because iframe only need to think in chrome extension app, * which will deal multiple levels of nesting iframe. */ export function getNestedBoundingClientRect(node) { return node.getBoundingClientRect(); } export function getElementDimensions(domElement) { const calculatedStyle = window.getComputedStyle(domElement); return { borderLeft: Number.parseInt(calculatedStyle.borderLeftWidth, 10), borderRight: Number.parseInt(calculatedStyle.borderRightWidth, 10), borderTop: Number.parseInt(calculatedStyle.borderTopWidth, 10), borderBottom: Number.parseInt(calculatedStyle.borderBottomWidth, 10), marginLeft: Number.parseInt(calculatedStyle.marginLeft, 10), marginRight: Number.parseInt(calculatedStyle.marginRight, 10), marginTop: Number.parseInt(calculatedStyle.marginTop, 10), marginBottom: Number.parseInt(calculatedStyle.marginBottom, 10), paddingLeft: Number.parseInt(calculatedStyle.paddingLeft, 10), paddingRight: Number.parseInt(calculatedStyle.paddingRight, 10), paddingTop: Number.parseInt(calculatedStyle.paddingTop, 10), paddingBottom: Number.parseInt(calculatedStyle.paddingBottom, 10), }; }