-
Notifications
You must be signed in to change notification settings - Fork 756
Description
CSSOM has an explicit algorithm for how to serialize CSS values. For colors, it says to serialize as rgb() vs rgba() depending on whether they have an alpha of one:
If is a component of a resolved or computed value, then return the color using the `rgb()` or `rgba()` functional notation as follows: 1. If the alpha component of the color is equal to one, then return the serialization of the `rgb()` functional equivalent of the opaque color. 2. If the alpha component of the color is not equal to one, then return the serialization of the `rgba()` functional equivalent of the non-opaque color.
https://drafts.csswg.org/cssom/#serializing-css-values
This makes perfect sense, in a world where rgb()/rgba() syntaxes differ (and where only rgba() allows for transparency).
HOWEVER, css-color-4 is broadening the rgb() syntax so that it accepts transparent colors. It only mentions rgba() as an afterthought, as an alias "with identical grammar" to rgb, which only exists "for legacy reasons":
https://drafts.csswg.org/css-color-4/#rgb-functions
SO: now that rgba() is a legacy alias, and it's trivial to serialize transparent colors with rgb(), should we simplify the CSSOM serialization algorithm to always use rgb()? Or should we hold onto its dependence on rgba(), for backwards-compat purposes with websites that might expect the old serialization behavior?
And, in particular -- if an author specifies e.g. color: rgb(10,20,30,0.5), are implementations expected to serialize that with rgba even though the author used rgb?