Skip to content

Commit b8660bd

Browse files
committed
Disable color calculation for utilities that obviously wont have them
1 parent d1312bd commit b8660bd

File tree

1 file changed

+13
-0
lines changed
  • packages/tailwindcss-language-service/src/util

1 file changed

+13
-0
lines changed

packages/tailwindcss-language-service/src/util/color.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,21 @@ function getColorFromRoot(state: State, css: postcss.Root): culori.Color | Keywo
188188
return getColorFromDecls(state, decls)
189189
}
190190

191+
let isNegative = /^-/
192+
let isNumericUtility =
193+
/^-?((min-|max-)?[wh]|z|start|order|opacity|rounded|row|col|size|basis|end|duration|ease|font|top|left|bottom|right|inset|leading|cursor|(space|scale|skew|rotate)-[xyz]|gap(-[xy])?|(scroll-)?[pm][trblxyse]?)-/
194+
195+
function isLikelyColorless(className: string) {
196+
if (isNegative.test(className)) return true
197+
if (isNumericUtility.test(className)) return true
198+
return false
199+
}
200+
191201
export function getColor(state: State, className: string): culori.Color | KeywordColor | null {
192202
if (state.v4) {
203+
// FIXME: This is a performance optimization and not strictly correct
204+
if (isLikelyColorless(className)) return null
205+
193206
let css = state.designSystem.compile([className])[0]
194207

195208
let color = getColorFromRoot(state, css)

0 commit comments

Comments
 (0)