Fix bug where color picker wouldn't parse uppercase values

pull/146/head
Cory LaViska 2020-07-27 07:36:17 -04:00
rodzic 1bfbd665fa
commit b4dfae2a79
1 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -396,7 +396,7 @@ export class ColorPicker {
// hex colors when the # is missing. This pre-parser tries to normalize these edge cases to provide a better // hex colors when the # is missing. This pre-parser tries to normalize these edge cases to provide a better
// experience for users who type in color values. // experience for users who type in color values.
// //
if (/rgba?/.test(colorString)) { if (/rgba?/i.test(colorString)) {
const rgba = colorString const rgba = colorString
.replace(/[^\d.%]/g, ' ') .replace(/[^\d.%]/g, ' ')
.split(' ') .split(' ')
@ -414,7 +414,7 @@ export class ColorPicker {
return `rgba(${rgba[0]}, ${rgba[1]}, ${rgba[2]}, ${rgba[3]})`; return `rgba(${rgba[0]}, ${rgba[1]}, ${rgba[2]}, ${rgba[3]})`;
} }
if (/hsla?/.test(colorString)) { if (/hsla?/i.test(colorString)) {
const hsla = colorString const hsla = colorString
.replace(/[^\d.%]/g, ' ') .replace(/[^\d.%]/g, ' ')
.split(' ') .split(' ')
@ -432,7 +432,7 @@ export class ColorPicker {
return `hsla(${hsla[0]}, ${hsla[1]}, ${hsla[2]}, ${hsla[3]})`; return `hsla(${hsla[0]}, ${hsla[1]}, ${hsla[2]}, ${hsla[3]})`;
} }
if (/^[0-9a-f]+$/.test(colorString)) { if (/^[0-9a-f]+$/i.test(colorString)) {
return `#${colorString}`; return `#${colorString}`;
} }