X Tutup
Skip to content

Commit f554b79

Browse files
farfromrefugNathanWalker
authored andcommitted
fix: css colors not parsed correctly within background property
1 parent c68d88d commit f554b79

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/core/css/parser.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ export function parseHexColor(text: string, start = 0): Parsed<Color> {
7575
return null;
7676
}
7777
const end = hexColorRegEx.lastIndex;
78-
return { start, end, value: new Color('#'+ result[1]) };
78+
return { start, end, value: new Color('#' + result[1]) };
7979
}
8080

81-
const cssColorRegEx = /\s*((?:rgb|rgba|hsl|hsla|hsv|hsva)\([^\(\)]\))/gy;
81+
const cssColorRegEx = /\s*((?:rgb|rgba|hsl|hsla|hsv|hsva)\([^\(\)]*\))/gy;
8282
export function parseCssColor(text: string, start = 0): Parsed<Color> {
8383
cssColorRegEx.lastIndex = start;
8484
const result = cssColorRegEx.exec(text);
@@ -87,11 +87,10 @@ export function parseCssColor(text: string, start = 0): Parsed<Color> {
8787
}
8888
const end = cssColorRegEx.lastIndex;
8989
try {
90-
return { start, end, value: new Color(text) };
90+
return { start, end, value: new Color(result[1]) };
9191
} catch {
9292
return null;
9393
}
94-
9594
}
9695

9796
export function convertHSLToRGBColor(hue: number, saturation: number, lightness: number): { r: number; g: number; b: number } {
@@ -132,7 +131,6 @@ export function convertHSLToRGBColor(hue: number, saturation: number, lightness:
132131
};
133132
}
134133

135-
136134
export function parseColorKeyword(value, start: number, keyword = parseKeyword(value, start)): Parsed<Color> {
137135
const parseColor = keyword && getKnownColor(keyword.value);
138136
if (parseColor != null) {

0 commit comments

Comments
 (0)
X Tutup