fixup for a=0, improve comment
This commit is contained in:
parent
a4dbe27b46
commit
13ca5b2808
|
@ -73,12 +73,13 @@ const BUILDERS = Object.assign(Object.create(null), {
|
||||||
case 'color':
|
case 'color':
|
||||||
value = colorConverter.parse(value) || null;
|
value = colorConverter.parse(value) || null;
|
||||||
if (value) {
|
if (value) {
|
||||||
/* `alpha` is present or `value` is opaque: #rrggbb
|
/* #rrggbb - inline alpha is present; an opaque hsl/a; #rrggbb originally
|
||||||
* `isUsoRgb`: r, g, b -- transparency is usually handled via a separate var
|
* rgba(r, g, b, a) - transparency <1 is present (Chrome pre-66 compatibility)
|
||||||
* `value` is transparent: rgba(r, g, b, a) -- for pre-66 Chrome
|
* rgb(r, g, b) - if color is rgb/a with a=1, note: r/g/b will be rounded
|
||||||
|
* r, g, b - if the var has `-rgb` suffix per USO specification
|
||||||
* TODO: when minimum_chrome_version >= 66 try to keep `value` intact */
|
* TODO: when minimum_chrome_version >= 66 try to keep `value` intact */
|
||||||
if (alpha) delete value.a;
|
if (alpha) delete value.a;
|
||||||
const isRgb = isUsoRgb || value.type === 'rgb' || value.a > 0 && value.a < 1;
|
const isRgb = isUsoRgb || value.type === 'rgb' || value.a != null && value.a !== 1;
|
||||||
const usoMode = isUsoRgb || !isRgb;
|
const usoMode = isUsoRgb || !isRgb;
|
||||||
value = colorConverter.format(value, isRgb ? 'rgb' : 'hex', undefined, usoMode);
|
value = colorConverter.format(value, isRgb ? 'rgb' : 'hex', undefined, usoMode);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user