Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Refactor
  • Loading branch information
thecrypticace committed Aug 27, 2025
commit 9c340832b2a1e9c7859bc5717af04530fa088301
29 changes: 11 additions & 18 deletions packages/tailwindcss/src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,26 +351,19 @@ export function optimizeAst(

// Rule
else if (node.kind === 'rule') {
// Rules with `&` as the selector should be flattened
if (node.selector === '&') {
for (let child of node.nodes) {
let nodes: AstNode[] = []
transform(child, nodes, context, depth + 1)
if (nodes.length > 0) {
parent.push(...nodes)
}
}
let nodes: AstNode[] = []

for (let child of node.nodes) {
transform(child, nodes, context, depth + 1)
}

//
else {
let copy = { ...node, nodes: [] }
for (let child of node.nodes) {
transform(child, copy.nodes, context, depth + 1)
}
if (copy.nodes.length > 0) {
parent.push(copy)
}
if (nodes.length === 0) return

// Rules with `&` as the selector should be flattened
if (node.selector === '&') {
parent.push(...nodes)
} else {
parent.push({ ...node, nodes })
}
}

Expand Down