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

These arguments *are* pretty convincing, and being able to knock out #11747 would be nice. However...

> But this will generate squares right now, right? It seems to me that requiring a shared name to tie them together makes more sense than requiring different names to differentiate. As you say, if you accidentally end up with two random() functions with shared used values right now, they'll get accidentally tied together.

The issue with making a "default" random() (without an explicit caching key) assume a unique key is that it's not very clear to authors *when* such a key would be generated. For example:

```css
.rectangle {
  /* these would be different random values */
  width: random(10px, 100px);
  height: random(10px, 100px);
}

.rectangle-2 {
  /* these would be different random values */
  --size: random(10px, 100px);
  width: var(--size);
  height: var(--size);
}

@property --size2 { syntax: "<length>"; inherits: true; initial-value: 0px; }
.square {
  /* these would be the *same* random value, making squares */
  --size2: random(10px, 100px);
  width: var(--size);
  height: var(--size);
}
```

To an extent authors already have this confusion, since `--foo: 1em;` has different inherited behavior for registered vs unregistered custom props, but this random() behavior would make it visible even *before* inheritance. (Technically the same behavior distinction *also* occurs for values like `1em`, it just doesn't matter in practical terms whether `1em` resolves in the custom prop or in the substituting prop.)

This is how I arrived at the current caching behavior - it can result in accidentally linked random values sometimes, but it also ensures that authors don't have to care about when the substitution occurs.

So, hm, tradeoffs either way. Maybe it is better to force authors to think about the variable resolution time in return for having "more random" behavior by default and avoiding the value-resolution dependence.

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


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

Received on Monday, 24 February 2025 23:30:24 UTC