Home / File/ setTextContent.js — react Source File

setTextContent.js — react Source File

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

File javascript BabelCompiler Validation 1 imports 2 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  f99cb5ea_d80a_0cbe_916e_6463e19449a5["setTextContent.js"]
  79306122_0617_c4ea_94ca_a596414f3150["HTMLNodeType.js"]
  f99cb5ea_d80a_0cbe_916e_6463e19449a5 --> 79306122_0617_c4ea_94ca_a596414f3150
  1e990658_7cea_75be_1f24_2399bdf9f15b["ReactDOMComponent.js"]
  1e990658_7cea_75be_1f24_2399bdf9f15b --> f99cb5ea_d80a_0cbe_916e_6463e19449a5
  9c694103_7f39_88d0_6b4d_f9b2ffed5731["ReactFiberConfigDOM.js"]
  9c694103_7f39_88d0_6b4d_f9b2ffed5731 --> f99cb5ea_d80a_0cbe_916e_6463e19449a5
  style f99cb5ea_d80a_0cbe_916e_6463e19449a5 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
 */

import {TEXT_NODE} from './HTMLNodeType';

/**
 * Set the textContent property of a node. For text updates, it's faster
 * to set the `nodeValue` of the Text node directly instead of using
 * `.textContent` which will remove the existing node and create a new one.
 *
 * @param {DOMElement} node
 * @param {string} text
 * @internal
 */
function setTextContent(node: Element, text: string): void {
  if (text) {
    const firstChild = node.firstChild;

    if (
      firstChild &&
      firstChild === node.lastChild &&
      firstChild.nodeType === TEXT_NODE
    ) {
      firstChild.nodeValue = text;
      return;
    }
  }
  node.textContent = text;
}

export default setTextContent;

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does setTextContent.js do?
setTextContent.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 setTextContent.js?
setTextContent.js defines 1 function(s): setTextContent.
What does setTextContent.js depend on?
setTextContent.js imports 1 module(s): HTMLNodeType.js.
What files import setTextContent.js?
setTextContent.js is imported by 2 file(s): ReactDOMComponent.js, ReactFiberConfigDOM.js.
Where is setTextContent.js in the architecture?
setTextContent.js is located at packages/react-dom-bindings/src/client/setTextContent.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