Skip to content

Commit

Permalink
cleanup unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Feb 5, 2025
1 parent 8f74b3e commit c0cc98c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions packages/tailwindcss/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,15 +667,13 @@ export async function compileAst(
}

let didChange = false
let emitNewCssVariables = false

// Add all new candidates unless we know that they are invalid.
let prevSize = allValidCandidates.size
for (let candidate of newRawCandidates) {
if (!designSystem.invalidCandidates.has(candidate)) {
if (candidate[0] === '-' && candidate[1] === '-') {
emitNewCssVariables = designSystem.theme.markUsedVariable(candidate)
didChange ||= emitNewCssVariables
designSystem.theme.markUsedVariable(candidate)
} else {
allValidCandidates.add(candidate)
}
Expand All @@ -697,7 +695,7 @@ export async function compileAst(
// If no new ast nodes were generated, then we can return the original
// CSS. This currently assumes that we only add new ast nodes and never
// remove any.
if (previousAstNodeCount === newNodes.length && !emitNewCssVariables) {
if (previousAstNodeCount === newNodes.length) {
compiled ??= optimizeAst(ast, designSystem)
return compiled
}
Expand Down
5 changes: 2 additions & 3 deletions packages/tailwindcss/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,10 @@ export class Theme {
markUsedVariable(themeKey: string) {
let key = unescape(this.#unprefixKey(themeKey))
let value = this.values.get(key)
if (!value) return false // Unknown variable
if (value.options & ThemeOptions.USED) return false // Variable already used
if (!value) return // Unknown variable
if (value.options & ThemeOptions.USED) return // Variable already used

value.options |= ThemeOptions.USED
return true
}

resolve(candidateValue: string | null, themeKeys: ThemeKey[]): string | null {
Expand Down

0 comments on commit c0cc98c

Please sign in to comment.