Re: [csswg-drafts] [css-values-5] Maybe min, max and step should not be part of the random-caching-key (#11742)

Re: per iteration randomness, I agree that using the custom-ident option is the right answer here. If we tried to randomize per keyframe, as in Kevin's example, then it brings in the same issues/confusion that randomizing based on style rule would. Is there a difference between `0% { width: random(...): }, 50% { width: random(...): }` and `0%, 50% { width: random(...); }`? Both "yes" and "no" are confusing. Relying on authors to solve this themselves with a random ident makes the answer clear.

That said, if it is something we do end up wanting to support more automatically, I think the right answer is that the auto-generated key would, in addition to the property/index, incorporate the *keyframes name* and *keyframe index*. That would mean that each instance of `random()` in Kevin's example would be distinct by default.

------

> I was wondering about a case where one toggles some class with randomness on an element [example toggling a class on and off]

Correct, that would be the same random value every time the class applied.

I'm pretty opposed to a "generation key" for this, as it would make things distinct in unexpected cases, like `.foo { width: random(match-element, 100px, 200px); }` when applied to elements that can be streamed in - if two elements appears in distinct styling passes they'd get distinct random values rather than sharing. It would also mean, I expect, that an element would change all its random values if you toggled `display:none` on and off.

If you're using scripting and want random values, you can always supply them yourself, at exactly the sharing granularity you desire.

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


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

Received on Thursday, 20 March 2025 22:06:53 UTC