Skip to content

[css-values-5] Names of the random-name keywords #13601

@tabatkins

Description

@tabatkins

In #13132 we resolved to change how the random functions' caching key controls work, switching to a name-based model instead to better match author intention. That is:

  • random(1, 10) is max-random: virtually every instance on the page will be a different random value
  • random(--foo, 1, 10) is min-random: every function that uses --foo will get the same random value

If you supply a dashed-ident name, you can also specify keywords that "mix in" certain aspects of the usage into the name to make it a little more unique, giving you intermediate-level randomness where some instances share the random value but others don't.

Per the resolution (and per the spec in a bit when I edit it in), the current keywords are:

  • random(--foo element, 1, 10) mixes in an element identifier, so usages on an element will all share the random value, but different elements will get different values
  • random(--foo property, 1, 10) mixes in the property name, so usages in a single property will share the random value (still global across elements), but using it in different properties gives a different value
  • random(--foo property index, 1, 10) mixes in the property name and the random function's index in the property, so multiple usages even in the same property will get different values.

(You can also mix them; random(--foo element property index, 1, 10) is basically identical to the max-randomness random(1, 10) use, except it can separate out some usages in weird corner cases that would otherwise become identical.)


We resolved to accept these suggested keywords, but to open a new issue to discuss their exact spelling.

If anyone has alternate ideas they'd like to champion, feel free. (Otherwise, we'll just stick with the resolution.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions