Skip to content

Commit ba21a2f

Browse files
committed
fix color detection
1 parent febded6 commit ba21a2f

File tree

1 file changed

+4
-12
lines changed
  • packages/tailwindcss-language-service/src/util

1 file changed

+4
-12
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,10 @@ const colorRegex = new RegExp(
5151
function getColorsInString(str: string): (culori.Color | KeywordColor)[] {
5252
if (/(?:box|drop)-shadow/.test(str)) return []
5353

54-
return (
55-
str
56-
.match(colorRegex)
57-
?.map((color) =>
58-
color
59-
.trim()
60-
.replace(/^[,(]|[,)]$/g, '')
61-
.replace(/var\([^)]+\)/, '1')
62-
)
63-
.map((color) => getKeywordColor(color) ?? culori.parse(color))
64-
.filter(Boolean) ?? []
65-
)
54+
return Array.from(str.matchAll(colorRegex), (match) => {
55+
let color = match[1].replace(/var\([^)]+\)/, '1')
56+
return getKeywordColor(color) ?? culori.parse(color)
57+
}).filter(Boolean)
6658
}
6759

6860
function getColorFromDecls(

0 commit comments

Comments
 (0)