Home / File/ cloneStyleTags.js — react Source File

cloneStyleTags.js — react Source File

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

Entity Profile

Dependency Diagram

graph LR
  bc0f1bd7_8cdc_bacd_b06e_18d931189032["cloneStyleTags.js"]
  b5e42467_7633_e234_1d51_a93bfc4818c7["index.js"]
  b5e42467_7633_e234_1d51_a93bfc4818c7 --> bc0f1bd7_8cdc_bacd_b06e_18d931189032
  style bc0f1bd7_8cdc_bacd_b06e_18d931189032 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 function cloneStyleTags(): Array<HTMLLinkElement | HTMLStyleElement> {
  const tags: Array<HTMLLinkElement | HTMLStyleElement> = [];

  // eslint-disable-next-line no-for-of-loops/no-for-of-loops
  for (const linkTag of document.getElementsByTagName('link')) {
    if (linkTag.rel === 'stylesheet') {
      const newLinkTag = document.createElement('link');

      // eslint-disable-next-line no-for-of-loops/no-for-of-loops
      for (const attribute of linkTag.attributes) {
        newLinkTag.setAttribute(attribute.nodeName, attribute.nodeValue);
      }

      tags.push(newLinkTag);
    }
  }

  // eslint-disable-next-line no-for-of-loops/no-for-of-loops
  for (const styleTag of document.getElementsByTagName('style')) {
    const newStyleTag = document.createElement('style');

    // eslint-disable-next-line no-for-of-loops/no-for-of-loops
    for (const attribute of styleTag.attributes) {
      newStyleTag.setAttribute(attribute.nodeName, attribute.nodeValue);
    }

    newStyleTag.textContent = styleTag.textContent;

    tags.push(newStyleTag);
  }

  return tags;
}

Domain

Frequently Asked Questions

What does cloneStyleTags.js do?
cloneStyleTags.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What files import cloneStyleTags.js?
cloneStyleTags.js is imported by 1 file(s): index.js.
Where is cloneStyleTags.js in the architecture?
cloneStyleTags.js is located at packages/react-devtools-extensions/src/main/cloneStyleTags.js (domain: BabelCompiler, directory: packages/react-devtools-extensions/src/main).

Analyze Your Own Codebase

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

Try Supermodel Free