Closed kajkal closed 5 months ago
I like this idea. I'd rename the flag to simply alpha
and use the enums "always"
, "never"
, "auto"
.
alpha is required (
rgba
,hsla
)
Alpha is never required even for rgba()
and hsla()
, although it used to be (CSS Color 3 and earlier). This is true of both the legacy (comma-separated) and modern syntactic forms.
This has now been implemented and will be in the upcoming v0.6.0 release. You can use alpha: true
to force alpha even when it's 100%, alpha: false
to prevent alpha from showing up, and commas: true
to force commas. These together should give you the result you were looking for, even though as @svgeesus said, the current output is perfectly valid.
There is this bug:
the fix is to check
format.lastAlpha
flag in the serialize.js function:However, is it necessary to have two flags to determine whether a given format should include alpha? To my knowledge, there are only 3 cases: 1) alpha is required (
rgba
,hsla
) 2) alpha is optional (alpha < 1
rgb
/hsl
for CSS Color 4) 3) alpha is ignored (rgb_number
)So the final flag should have 3 values, this can be achieved by, for example:
Is there something I don't know about or can I make PR to merge
noAlpha
andlastAlpha
flags into one?