Home / Function/ removeJSXAttributes() — react Function Reference

removeJSXAttributes() — react Function Reference

Architecture documentation for the removeJSXAttributes() function in minimize.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  5345709e_f0e2_f1f9_6d0b_dd1491e50449["removeJSXAttributes()"]
  9c061da8_dbf8_4168_823d_991654a3c55d["minimize.ts"]
  5345709e_f0e2_f1f9_6d0b_dd1491e50449 -->|defined in| 9c061da8_dbf8_4168_823d_991654a3c55d
  7a9af496_ef6a_d9e8_8eaf_1f386f49e4b3["cloneAst()"]
  5345709e_f0e2_f1f9_6d0b_dd1491e50449 -->|calls| 7a9af496_ef6a_d9e8_8eaf_1f386f49e4b3
  style 5345709e_f0e2_f1f9_6d0b_dd1491e50449 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/snap/src/minimize.ts lines 1356–1390

function* removeJSXAttributes(ast: t.File): Generator<t.File> {
  // Collect all JSX elements with their attribute counts
  const jsxSites: Array<{jsxIndex: number; attrCount: number}> = [];
  let jsxIndex = 0;
  t.traverseFast(ast, node => {
    if (t.isJSXOpeningElement(node) && node.attributes.length > 0) {
      jsxSites.push({jsxIndex, attrCount: node.attributes.length});
      jsxIndex++;
    }
  });

  // For each JSX element, try removing each attribute one at a time (from end to start)
  for (const {jsxIndex: targetJsxIdx, attrCount} of jsxSites) {
    for (let attrIdx = attrCount - 1; attrIdx >= 0; attrIdx--) {
      const cloned = cloneAst(ast);
      let idx = 0;
      let modified = false;

      t.traverseFast(cloned, node => {
        if (modified) return;
        if (t.isJSXOpeningElement(node) && node.attributes.length > 0) {
          if (idx === targetJsxIdx && attrIdx < node.attributes.length) {
            node.attributes.splice(attrIdx, 1);
            modified = true;
          }
          idx++;
        }
      });

      if (modified) {
        yield cloned;
      }
    }
  }
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does removeJSXAttributes() do?
removeJSXAttributes() is a function in the react codebase, defined in compiler/packages/snap/src/minimize.ts.
Where is removeJSXAttributes() defined?
removeJSXAttributes() is defined in compiler/packages/snap/src/minimize.ts at line 1356.
What does removeJSXAttributes() call?
removeJSXAttributes() calls 1 function(s): cloneAst.

Analyze Your Own Codebase

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

Try Supermodel Free