Fix invalid named color detection
If the named color is invalid, the value is not stored into the property.
This commit is contained in:
@@ -45,10 +45,14 @@ export function asString(color) {
|
||||
function fromNamed(color) {
|
||||
const el = document.createElement('div');
|
||||
el.style.color = color;
|
||||
document.body.appendChild(el);
|
||||
const rgb = getComputedStyle(el).color;
|
||||
document.body.removeChild(el);
|
||||
return rgb;
|
||||
if (el.style.color !== '') {
|
||||
document.body.appendChild(el);
|
||||
const rgb = getComputedStyle(el).color;
|
||||
document.body.removeChild(el);
|
||||
return rgb;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user