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

Function exit

packages/tailwindcss/src/intellisense.ts:188–227  ·  view source on GitHub ↗
(node, ctx)

Source from the content-addressed store, hash-verified

186 // this is more visible for things like group-*, not-*, etc…
187 walk(node.nodes, {
188 exit(node, ctx) {
189 if (node.kind !== 'rule' && node.kind !== 'at-rule') return
190 if (node.nodes.length > 0) return
191
192 let path = ctx.path()
193 path.push(node)
194
195 // Sort at-rules before style rules
196 path.sort((a, b) => {
197 let aIsAtRule = a.kind === 'at-rule'
198 let bIsAtRule = b.kind === 'at-rule'
199
200 if (aIsAtRule && !bIsAtRule) return -1
201 if (!aIsAtRule && bIsAtRule) return 1
202
203 return 0
204 })
205
206 // A list of the selectors / at rules encountered to get to this point
207 let group = path.flatMap((node) => {
208 if (node.kind === 'rule') {
209 return node.selector === '&' ? [] : [node.selector]
210 }
211
212 if (node.kind === 'at-rule') {
213 return [`${node.name} ${node.params}`]
214 }
215
216 return []
217 })
218
219 // Build a v3-style nested selector
220 let selector = ''
221
222 for (let i = group.length - 1; i >= 0; i--) {
223 selector = selector === '' ? group[i] : `${group[i]} { ${selector} }`
224 }
225
226 selectors.push(selector)
227 },
228 })
229
230 return selectors

Callers

nothing calls this directly

Calls 2

pathMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected