mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Cast malformed color hex strings to black
This commit is contained in:
parent
f5ce73ae51
commit
112989da0e
1 changed files with 3 additions and 0 deletions
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue