- From: fantasai via GitHub <sysbot+gh@w3.org>
- Date: Wed, 05 Mar 2025 22:39:41 +0000
- To: public-css-archive@w3.org
Definitely `random()` shouldn't infer a caching key from its source declaration. But I think we can and should give it maximum randomness unless the author explicitly ties things together. Randomness needs to resolve at computed-value time. That's required for it to inherit sensibly. Given that, I think each `random()` instance (unless otherwise specified by the author) should compute independently. If you specify the same `random()` function twice in a single property on a single element, or on two different properties, or on two different elements, they would compute to different values. Essentially, if you don't specify a caching key, we throw in the property name, an index (this is the Nth `random()` in the value), and the element identity as the caching key. Then if the author wants to tie things together, they can do that explicitly. Two `random()` functions compute to the same value if they share an identifier, with `per-element` essentially subbing in the element's identity. So `random(--foo, 1, 10)` always computes to the same value across the entire page; and `random(per-element, 1, 10)` always computes to the same value on a single element, but different values on different elements; and `random(per-element --foo, 1, 10)` computes differently than `random(per-element --bar, 1, 10)`. Yes, that means registered custom properties behave differently because they compute things up front. But that's already true, [as you point out](https://github.com/w3c/csswg-drafts/issues/11742#issuecomment-2679931790). <hr> The one other thing to be careful of is shorthand properties. We _probably_ want `margin: random(1, 10)` to resolve to the same random value on all four sides simply because if we don't, then splitting a property into longhands later becomes problematic. (Also it's a reasonable expectation for shorthands, to duplicate the value.) We can solve this by saying that `random()` is keyed to a property before shorthand expansion. -- GitHub Notification of comment by fantasai Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11742#issuecomment-2702238937 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 5 March 2025 22:39:42 UTC