Re: [csswg-drafts] Introduce `self()` function [css-values] (#9459)

Isn't this basically "`var()` for any property"? That is a common request, and avoiding circularity is more complex than it seems (see [this reply](https://github.com/w3c/csswg-drafts/issues/5729#issuecomment-736740685) by @tabatkins ).

Coincidentally, I posted a proposal a few days ago to reduce implementation complexity: https://github.com/w3c/csswg-drafts/issues/9454 
I discussed it privately with @tabatkins who said it certainly avoids some of the issues, but is still a lot of work, and is unconvinced about the value-add since authors can always use variables.

Note that your code above would not work properly even if `self()` was a thing. You need to add:

```css
@property --nested-radius {
 syntax: "<length>+"; /* <length>{1,4} not currently supported */
 inherits: true;
 initial-value: 0;
}
```

This will make the lengths actually resolve and get passed down as lengths. Right now they just get inherited as tokens, and interpreted on the point of usage, so `self()` will refer to child, and this be circular.

However, your code as specified doesn't actually *need* `self()` to be a thing. Since you're only referencing parent properties, [`inherit()`](https://github.com/w3c/csswg-drafts/issues/2864) would work just fine, and it's already accepted by the WG (spec pending, though L1 will just be custom properties). Solving the use case properly *would* require `self()`/`var()`, but only to take child margins into account.


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


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

Received on Thursday, 12 October 2023 14:17:29 UTC