mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
fix: css colors not parsed correctly within background property
This commit is contained in:
@ -78,7 +78,7 @@ export function parseHexColor(text: string, start = 0): Parsed<Color> {
|
||||
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<Color> {
|
||||
cssColorRegEx.lastIndex = start;
|
||||
const result = cssColorRegEx.exec(text);
|
||||
@ -87,11 +87,10 @@ export function parseCssColor(text: string, start = 0): Parsed<Color> {
|
||||
}
|
||||
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<Color> {
|
||||
const parseColor = keyword && getKnownColor(keyword.value);
|
||||
if (parseColor != null) {
|
||||
|
Reference in New Issue
Block a user