utils.js — react Source File
Architecture documentation for utils.js, a javascript file in the react codebase. 0 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR 68d130b4_8767_c9b9_03b4_1510bf2fc934["utils.js"] 5b39fc3a_1731_1aaf_f727_b3222027f445["Overlay.js"] 5b39fc3a_1731_1aaf_f727_b3222027f445 --> 68d130b4_8767_c9b9_03b4_1510bf2fc934 2e686050_4065_de33_2d80_1361879d66c9["canvas.js"] 2e686050_4065_de33_2d80_1361879d66c9 --> 68d130b4_8767_c9b9_03b4_1510bf2fc934 c252378b_d680_96f7_afbe_5200374b78e8["index.js"] c252378b_d680_96f7_afbe_5200374b78e8 --> 68d130b4_8767_c9b9_03b4_1510bf2fc934 style 68d130b4_8767_c9b9_03b4_1510bf2fc934 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
export interface Rect {
bottom: number;
height: number;
left: number;
right: number;
top: number;
width: number;
}
// Get the window object for the document that a node belongs to,
// or return null if it cannot be found (node not attached to DOM,
// etc).
export function getOwnerWindow(node: HTMLElement): typeof window | null {
if (!node.ownerDocument) {
return null;
}
return node.ownerDocument.defaultView;
}
// Get the iframe containing a node, or return null if it cannot
// be found (node not within iframe, etc).
export function getOwnerIframe(node: HTMLElement): HTMLElement | null {
const nodeWindow = getOwnerWindow(node);
if (nodeWindow) {
return nodeWindow.frameElement;
}
return null;
}
// Get a bounding client rect for a node, with an
// offset added to compensate for its border.
export function getBoundingClientRectWithBorderOffset(node: HTMLElement): Rect {
const dimensions = getElementDimensions(node);
// $FlowFixMe[incompatible-variance]
return mergeRectOffsets([
node.getBoundingClientRect(),
{
top: dimensions.borderTop,
left: dimensions.borderLeft,
bottom: dimensions.borderBottom,
right: dimensions.borderRight,
// This width and height won't get used by mergeRectOffsets (since this
// is not the first rect in the array), but we set them so that this
// object type checks as a ClientRect.
width: 0,
height: 0,
},
]);
}
// Add together the top, left, bottom, and right properties of
// ... (109 more lines)
Domain
Subdomains
Functions
Imported By
Source
Frequently Asked Questions
What does utils.js do?
utils.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in utils.js?
utils.js defines 1 function(s): getBoundingClientRectWithBorderOffset.
What files import utils.js?
utils.js is imported by 3 file(s): Overlay.js, canvas.js, index.js.
Where is utils.js in the architecture?
utils.js is located at packages/react-devtools-shared/src/backend/views/utils.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/backend/views).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free