Skip to content

[css-values-5] What order to use for the "index of usage" for the default random() keys? #13337

@tabatkins

Description

@tabatkins

If you don't specify a dashed-ident in the caching key for random(), one is auto-generated for you using the property name and the index of the random function among other random functions in that value. For example, border-width: random(0px, 10px) random(10px, 20px);, it's equivalent to writing border-width: random(--bw0, 0px, 10px) random(--bw1, 10px, 20px);. This ensures that two random() functions in a value aren't accidentally linked, but also that when a shorthand implicitly repeats a value, it'll use the same value.

However, the spec doesn't specify exactly what this "order of appearance" is. It appears that Safari uses the order of appearance in the specified value, while Blink uses the "normalized" order that would result from serialization.

For example, given the following styles:

.foo {
  box-shadow: calc(10px * random(1, 10)) 10px rgb(255 random(1, 10) 100);
}
.foo:hover {
  box-shadow: rgb(255 random(1, 10) 100) calc(10px * random(1, 10)) 10px;
}

If you hover and unhover the element, do you see a change or not? In Safari you see a change - if the first style generates numbers 3 and 7 (creating 30px 10px rgb(255 7 100), then the second style will swap what those 3 and 7 are used for (creating 70px 10px rgb(255 3 100)). In Blink there's no change.

I don't have much an opinion on which we should go with - linkage across declarations is accidental and not meant to be depended on. So I think it's just what is more natural for implementations. Thoughts?

/cc @tursunova and I think @nt1m ?

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