Re: [csswg-drafts] [css-color-5] Add `currentBackgroundColor` Variable (#5292)

> At the end, I don't understand what value this proposal really adds on top of the ability to customize interpolation of variables especially given its additional complexity. Could anyone explain?

The way I see it, decoupling. Variables are essentially a "contract" between two parts of CSS code. A library that uses variables needs the host CSS to know about it and its variable names to be useful. And if the library is changed, these properties would likely need to change as well. Whereas with something like this, one can write code that augments existing websites without their code needing any adjustment and without the indirection of reflecting real properties with custom properties.

> There are some other potential footguns, while possibly minor, should be taken into account as well for the new extended `current()` proposal, such as
> 
> * would it over shorthand works, e.g. `current(border-color)`?
> * what happens if we convert a longhand color property to a shorthand, e.g. maybe making `outline-color` a shorthand just like border?

Please note that my proposal is entirely about syntax. It is not for a more powerful feature than what @una proposes, just for one that has the **future potential** to become more powerful. I wasn't suggesting we add all color properties to it, just to go with a syntax that **allows us** to do so at some point in the future, if we so decide and use cases come up. We don't need to resolve all issues that come with that now which would delay and potentially stall it, but only when and if we decide to extend the syntax. 

But to answer your shorthand question (good point about future shorthands! Do note that `color` and `background-color` are theoretically not exempt from that either), if the serialized value makes the declaration invalid, then the declaration can be invalid at computed value time, just like `var()`.

The point about cycles is the same regardless of whether we go with keywords or a functional notation. 



-- 
GitHub Notification of comment by LeaVerou
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5292#issuecomment-725446680 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 11 November 2020 14:14:50 UTC