Re: [csswg-drafts] [css-values-4] Allow `inherit` in `calc()` (and friends), `color-mix()`, RCS (#9757)

@Loirooriol 
> Consider
> 
> ```css
> #el { --foo: 1 + 2 }
> #el > * { --foo: calc(inherit * 2); z-index: var(--foo) }
> ```
> 
> should `z-index` be `(1 + 2) * 2 = 6` or `1 + 2 * 2 = 5`?

Not sure where you see the ambiguity. Please note that:
* ( `var(--foo)` refers to the value of `--foo` on the current element, not the parent
* There is already [language](https://drafts.csswg.org/css-variables/#:~:text=That%20is%2C%20they%E2%80%99re%20interpreted%20at%20cascaded%2Dvalue%20time%20as%20normal) in the custom properties spec that CSS-wide keywords are resolved and not passed around as tokens

In your example, if `--foo` is unregistered, its inherited value would be the token stream `1 + 2`, making `--foo` on `#el > *` be `calc(1 + 2 * 2)`, which would be `5`. If `--foo` is registered as a `<number>` or `<integer>`, the value is invalid, and thus it would be IACVT, making `--foo` on the child also IACVT.  If custom properties could be registered as [`<calc-sum>`](https://drafts.csswg.org/css-values/#typedef-calc-sum), then it would be inherited as 3, making `--foo` on the child 6, and thus also `z-index` would be 6.

> Also, it's not clear if you are proposing this just for custom properties (with the idea to extend it to all properties in the future), or if you want it for all properties now. I'm concerned about the same serialization inconsistencies from #2864.

Per my edit, custom properties and a restricted set of regular properties TBD. Worst case we could start from custom properties, but I'm hoping since this is a much more restricted feature, we could broaden scope a bit.

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


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

Received on Saturday, 30 December 2023 18:00:18 UTC