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

Function candidatesToAst

packages/tailwindcss/src/design-system.ts:114–144  ·  view source on GitHub ↗
(classes: string[])

Source from the content-addressed store, hash-verified

112 })
113
114 function candidatesToAst(classes: string[]): AstNode[][] {
115 let result: AstNode[][] = []
116
117 for (let className of classes) {
118 let wasValid = true
119
120 let { astNodes } = compileCandidates([className], designSystem, {
121 onInvalidCandidate() {
122 wasValid = false
123 },
124 })
125
126 if (utilitiesSrc) {
127 walk(astNodes, (node) => {
128 // We do this conditionally to preserve source locations from both
129 // `@utility` and `@custom-variant`. Even though generated nodes are
130 // cached this should be fine because `utilitiesNode.src` should not
131 // change without a full rebuild which destroys the cache.
132 node.src ??= utilitiesSrc
133 return WalkAction.Continue
134 })
135 }
136
137 // Disable all polyfills to not unnecessarily pollute IntelliSense output
138 astNodes = optimizeAst(astNodes, designSystem, Polyfills.None)
139
140 result.push(wasValid ? astNodes : [])
141 }
142
143 return result
144 }
145
146 function candidatesToCss(classes: string[]): (string | null)[] {
147 return candidatesToAst(classes).map((nodes) => {

Callers 1

candidatesToCssFunction · 0.85

Calls 3

compileCandidatesFunction · 0.90
walkFunction · 0.90
optimizeAstFunction · 0.90

Tested by

no test coverage detected