getOffsets() — react Function Reference
Architecture documentation for the getOffsets() function in ReactDOMSelection.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD f22fbac9_78b0_dbd3_6b8a_d487d7efa09e["getOffsets()"] 5672f9bd_6a0a_e8f0_9857_0fb959fc7759["ReactDOMSelection.js"] f22fbac9_78b0_dbd3_6b8a_d487d7efa09e -->|defined in| 5672f9bd_6a0a_e8f0_9857_0fb959fc7759 15b961e4_5bdf_3cdf_6282_36a44dfc92b2["getSelection()"] 15b961e4_5bdf_3cdf_6282_36a44dfc92b2 -->|calls| f22fbac9_78b0_dbd3_6b8a_d487d7efa09e 0895fc77_95ae_fed1_2bf7_43d55dc5cac0["getModernOffsetsFromPoints()"] f22fbac9_78b0_dbd3_6b8a_d487d7efa09e -->|calls| 0895fc77_95ae_fed1_2bf7_43d55dc5cac0 style f22fbac9_78b0_dbd3_6b8a_d487d7efa09e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom-bindings/src/client/ReactDOMSelection.js lines 15–49
export function getOffsets(outerNode) {
const {ownerDocument} = outerNode;
const win = (ownerDocument && ownerDocument.defaultView) || window;
const selection = win.getSelection && win.getSelection();
if (!selection || selection.rangeCount === 0) {
return null;
}
const {anchorNode, anchorOffset, focusNode, focusOffset} = selection;
// In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the
// up/down buttons on an <input type="number">. Anonymous divs do not seem to
// expose properties, triggering a "Permission denied error" if any of its
// properties are accessed. The only seemingly possible way to avoid erroring
// is to access a property that typically works for non-anonymous divs and
// catch any error that may otherwise arise. See
// https://bugzilla.mozilla.org/show_bug.cgi?id=208427
try {
/* eslint-disable ft-flow/no-unused-expressions */
anchorNode.nodeType;
focusNode.nodeType;
/* eslint-enable ft-flow/no-unused-expressions */
} catch (e) {
return null;
}
return getModernOffsetsFromPoints(
outerNode,
anchorNode,
anchorOffset,
focusNode,
focusOffset,
);
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does getOffsets() do?
getOffsets() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/ReactDOMSelection.js.
Where is getOffsets() defined?
getOffsets() is defined in packages/react-dom-bindings/src/client/ReactDOMSelection.js at line 15.
What does getOffsets() call?
getOffsets() calls 1 function(s): getModernOffsetsFromPoints.
What calls getOffsets()?
getOffsets() is called by 1 function(s): getSelection.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free