mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix: css colors not parsed correctly within background property
This commit is contained in:
@ -75,10 +75,10 @@ export function parseHexColor(text: string, start = 0): Parsed<Color> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const end = hexColorRegEx.lastIndex;
|
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<Color> {
|
export function parseCssColor(text: string, start = 0): Parsed<Color> {
|
||||||
cssColorRegEx.lastIndex = start;
|
cssColorRegEx.lastIndex = start;
|
||||||
const result = cssColorRegEx.exec(text);
|
const result = cssColorRegEx.exec(text);
|
||||||
@ -87,11 +87,10 @@ export function parseCssColor(text: string, start = 0): Parsed<Color> {
|
|||||||
}
|
}
|
||||||
const end = cssColorRegEx.lastIndex;
|
const end = cssColorRegEx.lastIndex;
|
||||||
try {
|
try {
|
||||||
return { start, end, value: new Color(text) };
|
return { start, end, value: new Color(result[1]) };
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convertHSLToRGBColor(hue: number, saturation: number, lightness: number): { r: number; g: number; b: number } {
|
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> {
|
export function parseColorKeyword(value, start: number, keyword = parseKeyword(value, start)): Parsed<Color> {
|
||||||
const parseColor = keyword && getKnownColor(keyword.value);
|
const parseColor = keyword && getKnownColor(keyword.value);
|
||||||
if (parseColor != null) {
|
if (parseColor != null) {
|
||||||
|
Reference in New Issue
Block a user