Comments (2)
The spec goes on to state:
The serialization of the result of a relative color function depends on whether the keyword currentColor is the origin color. If so, the result is serialized as the declared value. This allows the correct value to be used on child elements whose color property has a different value. Otherwise, it is the resolved value, which is a
<color>
, as defined in CSS Color 4 ยงโฏ 15. Serializing<color>
Values.
I understand this to mean:
- If the origin color is
currentColor
, then serialize the spelling as declared. (We don't know the origin color and thus cannot canonicalize it.) - If the origin color is not
currentColor
, then resolve the relative color and serialize canonically as described in Color 4.
There are few tests with examples for how canonicalization happens in case 2: color-valid.html, color-valid-rgb.html, color-valid-hsl.html. Notably:
hsla(...)
canonicalizes to equivalentrgba(...)
, andhsl(...)
canonicalizes to equivalentrgb(...)
rgb(...)
is used if the clamped alpha is exactly 1, otherwisergba(...)
is used
cc @svgeesus to confirm.
from csswg-drafts.
I filed a separate issue on the ambiguity here - #10305, as I don't think the current spec text is clear on what the rules are.
Regardless of that however, the question posed here remains, as you can just set currentColor as the origin:
That is, should:
rgb(from currentcolor r g b)
and
rgba(from currentcolor r g b)
serializations maintain the exact spelling of function name.
@kbabbitt, the tests you mention, notably, cover the absolute case, which has clear rules about which spelling to do, and those rules are not about what spelling was used at the declaration site, but rather about the resolved value of the alpha channel. As you might not know the value of the alpha channel in a relative color, the exact same rules can't be followed.
from csswg-drafts.
Related Issues (20)
- [css-anchor-position] Flat tree vs. anchor-scope HOT 3
- [css-color-5] Should colors nested in a parent color function (RCS, color-mix, light-dark, color-contrast) serialize in their most precision saving form HOT 10
- [css-pseudo-4] system colors for ::search-text HOT 1
- [css-will-change] new property will-change-to
- [mediaqueries-5] SVG images referenced by img elements do not respect prefers-color-scheme in forced-colors mode
- [css-ui] How do `appearance: none` and `appearance: auto` render the rich `<select>` markup? HOT 3
- [css-ui] New value(s) for the appearance property to support `<select>` stylability HOT 2
- [css-view-transitions-2] Proposal for a view-transition-tree property (name tbd) HOT 24
- [mediaqueries] CSS Media Feature for Color Vision Adjustments
- [css-cascade-6] reusable named scopes HOT 3
- [css-values-5] Should an arbitrary substitution nested within another be accepted in context?
- [css-values-5] Should `<whole-value>` functions be parsed before the declaration value range? HOT 3
- [css-anchor-position-1] position-try-options interaction with position-visibility
- [css-animation-1] Should non-animatable properties be accepted in keyframe rules?
- [css-ui] Proposal: allow multiple outlines per element HOT 2
- [cssom-view] Change `document.caretPositionFromPoint`'s `shadowRoots` parameter from rest parameter to an array HOT 9
- [cssom-1] A more direct method than `caretPositionFromPoint()` HOT 2
- [css-contain] content-visibility: auto and SVG-as-image HOT 10
- repo name nit: it'd be nice if this were simply w3c/csswg HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csswg-drafts.