MCPcopy
hub / github.com/tailwindlabs/tailwindcss / cssContext

Function cssContext

packages/tailwindcss/src/ast.ts:188–218  ·  packages/tailwindcss/src/ast.ts::cssContext
(
  ctx: VisitContext<AstNode>,
)

Source from the content-addressed store, hash-verified

186}
187
188export function cssContext(
189 ctx: VisitContext<AstNode>,
190): VisitContext<AstNode> & { context: Record<string, string | boolean> } {
191 return {
192 depth: ctx.depth,
193 index: ctx.index,
194 siblings: ctx.siblings,
195 get context() {
196 let context: Record<string, string | boolean> = {}
197 for (let child of ctx.path()) {
198 if (child.kind === class="st">'context') {
199 Object.assign(context, child.context)
200 }
201 }
202
203 class="cm">// Once computed, we never need to compute this again
204 Object.defineProperty(this, class="st">'context', { value: context })
205 return context
206 },
207 get parent() {
208 let parent = (this.path().pop() as Extract<AstNode, { nodes: AstNode[] }>) ?? null
209
210 class="cm">// Once computed, we never need to compute this again
211 Object.defineProperty(this, class="st">'parent', { value: parent })
212 return parent
213 },
214 path() {
215 return ctx.path().filter((n) => n.kind !== class="st">'context')
216 },
217 }
218}
219
220class="cm">// Optimize the AST for printing where all the special nodes that require custom
221class="cm">// handling are handled such that the printing is a 1-to-1 transformation.

Callers 4

parseCssFunction · 0.90
ast.test.tsFile · 0.90
applyCompatibilityHooksFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected