Home / File/ ReactInputSelection.js — react Source File

ReactInputSelection.js — react Source File

Architecture documentation for ReactInputSelection.js, a javascript file in the react codebase. 6 imports, 2 dependents.

File javascript BabelCompiler Validation 6 imports 2 dependents 10 functions

Entity Profile

Dependency Diagram

graph LR
  61ae92ed_59ee_0d03_f7cc_6c7bd8c060f5["ReactInputSelection.js"]
  fa8c5082_5952_1b00_ab76_4bbec8487a1d["getActiveElement.js"]
  61ae92ed_59ee_0d03_f7cc_6c7bd8c060f5 --> fa8c5082_5952_1b00_ab76_4bbec8487a1d
  73ae0fb8_77c3_8d4a_406e_dfdbac35c58c["getActiveElement"]
  61ae92ed_59ee_0d03_f7cc_6c7bd8c060f5 --> 73ae0fb8_77c3_8d4a_406e_dfdbac35c58c
  5672f9bd_6a0a_e8f0_9857_0fb959fc7759["ReactDOMSelection.js"]
  61ae92ed_59ee_0d03_f7cc_6c7bd8c060f5 --> 5672f9bd_6a0a_e8f0_9857_0fb959fc7759
  f22fbac9_78b0_dbd3_6b8a_d487d7efa09e["getOffsets"]
  61ae92ed_59ee_0d03_f7cc_6c7bd8c060f5 --> f22fbac9_78b0_dbd3_6b8a_d487d7efa09e
  51f6074d_96a6_e994_0a5d_3d79a9aab945["setOffsets"]
  61ae92ed_59ee_0d03_f7cc_6c7bd8c060f5 --> 51f6074d_96a6_e994_0a5d_3d79a9aab945
  79306122_0617_c4ea_94ca_a596414f3150["HTMLNodeType.js"]
  61ae92ed_59ee_0d03_f7cc_6c7bd8c060f5 --> 79306122_0617_c4ea_94ca_a596414f3150
  9c694103_7f39_88d0_6b4d_f9b2ffed5731["ReactFiberConfigDOM.js"]
  9c694103_7f39_88d0_6b4d_f9b2ffed5731 --> 61ae92ed_59ee_0d03_f7cc_6c7bd8c060f5
  b8a5c95d_02fb_4719_0efd_4463f2546996["SelectEventPlugin.js"]
  b8a5c95d_02fb_4719_0efd_4463f2546996 --> 61ae92ed_59ee_0d03_f7cc_6c7bd8c060f5
  style 61ae92ed_59ee_0d03_f7cc_6c7bd8c060f5 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.
 */

import getActiveElement from './getActiveElement';

import {getOffsets, setOffsets} from './ReactDOMSelection';
import {ELEMENT_NODE, TEXT_NODE} from './HTMLNodeType';

function isTextNode(node) {
  return node && node.nodeType === TEXT_NODE;
}

function containsNode(outerNode, innerNode) {
  if (!outerNode || !innerNode) {
    return false;
  } else if (outerNode === innerNode) {
    return true;
  } else if (isTextNode(outerNode)) {
    return false;
  } else if (isTextNode(innerNode)) {
    return containsNode(outerNode, innerNode.parentNode);
  } else if ('contains' in outerNode) {
    return outerNode.contains(innerNode);
  } else if (outerNode.compareDocumentPosition) {
    return !!(outerNode.compareDocumentPosition(innerNode) & 16);
  } else {
    return false;
  }
}

function isInDocument(node) {
  return (
    node &&
    node.ownerDocument &&
    containsNode(node.ownerDocument.documentElement, node)
  );
}

function isSameOriginFrame(iframe) {
  try {
    // Accessing the contentDocument of a HTMLIframeElement can cause the browser
    // to throw, e.g. if it has a cross-origin src attribute.
    // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g:
    // iframe.contentDocument.defaultView;
    // A safety way is to access one of the cross origin properties: Window or Location
    // Which might result in "SecurityError" DOM Exception and it is compatible to Safari.
    // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl

    return typeof iframe.contentWindow.location.href === 'string';
  } catch (err) {
    return false;
  }
}

function getActiveElementDeep(containerInfo) {
  let win =
// ... (140 more lines)

Domain

Subdomains

Frequently Asked Questions

What does ReactInputSelection.js do?
ReactInputSelection.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 ReactInputSelection.js?
ReactInputSelection.js defines 10 function(s): containsNode, getActiveElementDeep, getSelection, getSelectionInformation, hasSelectionCapabilities, isInDocument, isSameOriginFrame, isTextNode, restoreSelection, setSelection.
What does ReactInputSelection.js depend on?
ReactInputSelection.js imports 6 module(s): HTMLNodeType.js, ReactDOMSelection.js, getActiveElement, getActiveElement.js, getOffsets, setOffsets.
What files import ReactInputSelection.js?
ReactInputSelection.js is imported by 2 file(s): ReactFiberConfigDOM.js, SelectEventPlugin.js.
Where is ReactInputSelection.js in the architecture?
ReactInputSelection.js is located at packages/react-dom-bindings/src/client/ReactInputSelection.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-dom-bindings/src/client).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free