MCPcopy Create free account
hub / github.com/tailwindlabs/tailwindcss / toCss

Function toCss

packages/tailwindcss/src/selector-parser.ts:102–136  ·  view source on GitHub ↗
(ast: SelectorAstNode[], minify = false)

Source from the content-addressed store, hash-verified

100}
101
102export function toCss(ast: SelectorAstNode[], minify = false) {
103 let css = ''
104 for (let node of ast) {
105 switch (node.kind) {
106 case 'selector':
107 case 'value': {
108 css += node.value
109 break
110 }
111 case 'combinator': {
112 if (minify || node.value === ' ') {
113 css += node.value
114 } else {
115 css += ` ${node.value} `
116 }
117 break
118 }
119
120 case 'function': {
121 css += `${node.value}(${toCss(node.nodes, minify)})`
122 break
123 }
124 case 'complex':
125 case 'compound': {
126 css += toCss(node.nodes, minify)
127 break
128 }
129 case 'list': {
130 css += node.nodes.map((node) => toCss([node], minify)).join(minify ? ',' : ', ')
131 break
132 }
133 }
134 }
135 return css
136}
137
138const BACKSLASH = 0x5c
139const CLOSE_BRACKET = 0x5d

Callers 1

Calls 2

joinMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected