-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cssom][css-color] Need clarification on serialization of rgb
& rgba
in light of css-color-4's syntax changes
#585
Comments
rgb
& rgba
in light of css-color-4's syntax changes
If an author used rgb(10,20,30,0.5), that should be the way it's returned in the computed style. |
Pushing back slightly: what would be the point of maintaining state about whether the author used |
The value doesn't need to be returned exactly the same way it was set. If an author uses the new syntax, it would be weird if the computed style reflects to old legacy syntax. |
Note that the authored syntax is needed for debugging purposes. (Every browser development tool has an option to switch the display of colors to the authored value.) Besides that, I think it's fine to compute legacy Sebastian |
It's very likely that this is not the case as it will change existing behavior and script won't see the alpha anymore or get confused about the extra parameter |
Yes, it's likely. Though that's something that should be checked. Sebastian |
I suspect that we're trapped by legacy compat, and have to keep the existing CSSOM rules. If anyone would like to try and serialize to rgb(), tho, please be my guest. |
#1004 (comment) has resolutions for this issue |
All dealt with, CSSWG resolutions implemented, see see Serializing alpha values and Serializing sRGB values
CSS WG decided to go with legacy compat as much as possible. So values with a fully opaque alpha are output as
They are now, yes. @dholbert do these edits resolve all of your concerns? |
CSSOM has an explicit algorithm for how to serialize CSS values. For colors, it says to serialize as
rgb()
vsrgba()
depending on whether they have an alpha of one:https://drafts.csswg.org/cssom/#serializing-css-values
This makes perfect sense, in a world where
rgb()
/rgba()
syntaxes differ (and where onlyrgba()
allows for transparency).HOWEVER, css-color-4 is broadening the
rgb()
syntax so that it accepts transparent colors. It only mentionsrgba()
as an afterthought, as an alias "with identical grammar" torgb
, 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 withrgb()
, should we simplify the CSSOM serialization algorithm to always usergb()
? Or should we hold onto its dependence onrgba()
, 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 withrgba
even though the author usedrgb
?The text was updated successfully, but these errors were encountered: