Cast malformed color hex strings to black

This commit is contained in:
adroitwhiz 2020-05-01 14:38:18 -04:00
parent f5ce73ae51
commit 112989da0e

View file

@ -93,6 +93,9 @@ class Cast {
let color;
if (typeof value === 'string' && value.substring(0, 1) === '#') {
color = Color.hexToRgb(value);
// If the color wasn't *actually* a hex color, cast to black
if (!color) color = {r: 0, g: 0, b: 0, a: 255};
} else {
color = Color.decimalToRgb(Cast.toNumber(value));
}