Home / Function/ cloneAstNode() — tailwindcss Function Reference

cloneAstNode() — tailwindcss Function Reference

Architecture documentation for the cloneAstNode() function in ast.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  88bcab2f_f837_9e57_5b6a_fda72a4c3315["cloneAstNode()"]
  42640952_ea63_55f1_1ff1_00816e2980ae["ast.ts"]
  88bcab2f_f837_9e57_5b6a_fda72a4c3315 -->|defined in| 42640952_ea63_55f1_1ff1_00816e2980ae
  96876152_5423_5f9b_9f88_1db666070351["substituteAtApply()"]
  96876152_5423_5f9b_9f88_1db666070351 -->|calls| 88bcab2f_f837_9e57_5b6a_fda72a4c3315
  80a88206_fcce_6e85_32d2_3f5ca73e8b39["createUtilityPropertiesCache()"]
  80a88206_fcce_6e85_32d2_3f5ca73e8b39 -->|calls| 88bcab2f_f837_9e57_5b6a_fda72a4c3315
  75cdf0b0_3569_52fd_7186_577645fd4872["createCssUtility()"]
  75cdf0b0_3569_52fd_7186_577645fd4872 -->|calls| 88bcab2f_f837_9e57_5b6a_fda72a4c3315
  style 88bcab2f_f837_9e57_5b6a_fda72a4c3315 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/ast.ts lines 126–186

export function cloneAstNode<T extends AstNode>(node: T): T {
  switch (node.kind) {
    case 'rule':
      return {
        kind: node.kind,
        selector: node.selector,
        nodes: node.nodes.map(cloneAstNode),
        src: node.src,
        dst: node.dst,
      } satisfies StyleRule as T

    case 'at-rule':
      return {
        kind: node.kind,
        name: node.name,
        params: node.params,
        nodes: node.nodes.map(cloneAstNode),
        src: node.src,
        dst: node.dst,
      } satisfies AtRule as T

    case 'at-root':
      return {
        kind: node.kind,
        nodes: node.nodes.map(cloneAstNode),
        src: node.src,
        dst: node.dst,
      } satisfies AtRoot as T

    case 'context':
      return {
        kind: node.kind,
        context: { ...node.context },
        nodes: node.nodes.map(cloneAstNode),
        src: node.src,
        dst: node.dst,
      } satisfies Context as T

    case 'declaration':
      return {
        kind: node.kind,
        property: node.property,
        value: node.value,
        important: node.important,
        src: node.src,
        dst: node.dst,
      } satisfies Declaration as T

    case 'comment':
      return {
        kind: node.kind,
        value: node.value,
        src: node.src,
        dst: node.dst,
      } satisfies Comment as T

    default:
      node satisfies never
      throw new Error(`Unknown node kind: ${(node as any).kind}`)
  }
}

Domain

Subdomains

Frequently Asked Questions

What does cloneAstNode() do?
cloneAstNode() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/ast.ts.
Where is cloneAstNode() defined?
cloneAstNode() is defined in packages/tailwindcss/src/ast.ts at line 126.
What calls cloneAstNode()?
cloneAstNode() is called by 3 function(s): createCssUtility, createUtilityPropertiesCache, substituteAtApply.

Analyze Your Own Codebase

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

Try Supermodel Free