mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
Using Color.fromHex with invalid input should return null
This commit is contained in:
@@ -1032,9 +1032,13 @@ export class Color {
|
||||
return new Color(color.r, color.g, color.b, color.a / 255);
|
||||
}
|
||||
|
||||
static fromHex(hex: string): Color {
|
||||
const color = BaseColor.fromHex(hex).rgba;
|
||||
return new Color(color.r, color.g, color.b, color.a / 255);
|
||||
static fromHex(hex: string): Color | null {
|
||||
let baseColor = BaseColor.Format.CSS.parseHex(hex);
|
||||
if (baseColor) {
|
||||
const rgba = baseColor.rgba;
|
||||
return new Color(rgba.r, rgba.g, rgba.b, rgba.a / 255);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user