Home / Function/ cssContext() — tailwindcss Function Reference

cssContext() — tailwindcss Function Reference

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

Function typescript NodeBridge Compiler calls 1 called by 3

Entity Profile

Dependency Diagram

graph TD
  b50aa380_a654_a283_9fe1_91a9a42ca527["cssContext()"]
  42640952_ea63_55f1_1ff1_00816e2980ae["ast.ts"]
  b50aa380_a654_a283_9fe1_91a9a42ca527 -->|defined in| 42640952_ea63_55f1_1ff1_00816e2980ae
  fb60e614_817a_db22_d8eb_2bde7cd29719["applyCompatibilityHooks()"]
  fb60e614_817a_db22_d8eb_2bde7cd29719 -->|calls| b50aa380_a654_a283_9fe1_91a9a42ca527
  1a022c10_a26e_d793_740c_267a533619c4["upgradeToFullPluginSupport()"]
  1a022c10_a26e_d793_740c_267a533619c4 -->|calls| b50aa380_a654_a283_9fe1_91a9a42ca527
  3970218d_3d6c_e455_87cc_45b4a094f0e9["parseCss()"]
  3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| b50aa380_a654_a283_9fe1_91a9a42ca527
  2cb0bb18_cebb_3874_811d_77095e27cf0d["context()"]
  b50aa380_a654_a283_9fe1_91a9a42ca527 -->|calls| 2cb0bb18_cebb_3874_811d_77095e27cf0d
  style b50aa380_a654_a283_9fe1_91a9a42ca527 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/ast.ts lines 188–216

export function cssContext(
  ctx: VisitContext<AstNode>,
): VisitContext<AstNode> & { context: Record<string, string | boolean> } {
  return {
    depth: ctx.depth,
    get context() {
      let context: Record<string, string | boolean> = {}
      for (let child of ctx.path()) {
        if (child.kind === 'context') {
          Object.assign(context, child.context)
        }
      }

      // Once computed, we never need to compute this again
      Object.defineProperty(this, 'context', { value: context })
      return context
    },
    get parent() {
      let parent = (this.path().pop() as Extract<AstNode, { nodes: AstNode[] }>) ?? null

      // Once computed, we never need to compute this again
      Object.defineProperty(this, 'parent', { value: parent })
      return parent
    },
    path() {
      return ctx.path().filter((n) => n.kind !== 'context')
    },
  }
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does cssContext() do?
cssContext() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/ast.ts.
Where is cssContext() defined?
cssContext() is defined in packages/tailwindcss/src/ast.ts at line 188.
What does cssContext() call?
cssContext() calls 1 function(s): context.
What calls cssContext()?
cssContext() is called by 3 function(s): applyCompatibilityHooks, parseCss, upgradeToFullPluginSupport.

Analyze Your Own Codebase

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

Try Supermodel Free