diff --git a/packages/core/css/parser.ts b/packages/core/css/parser.ts index a2c2a546a..83c1ee1aa 100644 --- a/packages/core/css/parser.ts +++ b/packages/core/css/parser.ts @@ -75,10 +75,10 @@ export function parseHexColor(text: string, start = 0): Parsed { return null; } const end = hexColorRegEx.lastIndex; - return { start, end, value: new Color('#'+ result[1]) }; + return { start, end, value: new Color('#' + result[1]) }; } -const cssColorRegEx = /\s*((?:rgb|rgba|hsl|hsla|hsv|hsva)\([^\(\)]\))/gy; +const cssColorRegEx = /\s*((?:rgb|rgba|hsl|hsla|hsv|hsva)\([^\(\)]*\))/gy; export function parseCssColor(text: string, start = 0): Parsed { cssColorRegEx.lastIndex = start; const result = cssColorRegEx.exec(text); @@ -87,11 +87,10 @@ export function parseCssColor(text: string, start = 0): Parsed { } const end = cssColorRegEx.lastIndex; try { - return { start, end, value: new Color(text) }; + return { start, end, value: new Color(result[1]) }; } catch { return null; } - } 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: }; } - export function parseColorKeyword(value, start: number, keyword = parseKeyword(value, start)): Parsed { const parseColor = keyword && getKnownColor(keyword.value); if (parseColor != null) {