Re: [csswg-drafts] [css-values-5] The `<random-value-sharing>` options for `random()` are confusing (#13132)

The CSS Working Group just discussed ``[css-values-5] The `<random-value-sharing>` options for `random()` are confusing``, and agreed to the following:

* `RESOLVED: Supplying just an ident to the random() function produces a value that is globally shared`
* `RESOLVED: add keywords for element, property, and index portions of key, open separate issue for exact names`

<details><summary>The full IRC log of that discussion</summary>
&lt;kbabbitt> TabAtkins: we have the random function in the spec for a while<br>
&lt;kbabbitt> ... have some impl in Chrome<br>
&lt;kbabbitt> ... bramus has been chatting with authors and found there's some confusion on options<br>
&lt;kbabbitt> ... quick review:<br>
&lt;kbabbitt> ... you specify min max and stuff, not important here<br>
&lt;kbabbitt> ... important bit is how you control random caching<br>
&lt;kbabbitt> ... we can't expose evaluation semantics<br>
&lt;kbabbitt> ... we associate each random value with a caching key<br>
&lt;kbabbitt> ... as long as caching key is the same, you get same value back no matter how many times you eval<br>
&lt;kbabbitt> ... caching key contains property it's on, the index within the property, and some element identifier<br>
&lt;kbabbitt> ... these 3 otgether ensure virtually every usage of random() across stylesheet produces a distinct random number, but stable within a page load<br>
&lt;kbabbitt> ... can relax this by specifying some caching options<br>
&lt;kbabbitt> ... currently there's two of these in a spec<br>
&lt;kbabbitt> .. dashed-ident operridves property name + index<br>
&lt;kbabbitt> ... element-shared nulls out element identifier<br>
&lt;kbabbitt> ...; either of these makes different rand() more likely to be the same<br>
&lt;kbabbitt> ... when you use this fn on differen telement with same caching key, will share values<br>
&lt;kbabbitt> ... bramus found 2 things that confuse people<br>
&lt;kbabbitt> ... first when people used just a dashed-ident, expectation was they were giving random value a name and thus should get same value every time they used it<br>
&lt;kbabbitt> ... but as I just specified, that fn still contains an element specific identifier<br>
&lt;kbabbitt> ... which violates expectations when a user chosen dashed ident is there<br>
&lt;kbabbitt> ... second, people were confused about what access control shared element key did<br>
&lt;kbabbitt> ... as specified, random functions on different elements resolve to same thing<br>
&lt;kbabbitt> .. expected it to be shared within an element rather than across elements<br>
&lt;kbabbitt> ... this is just a bit of an author learning thing<br>
&lt;kbabbitt> ... could potentially say they'll learn abot it<br>
&lt;kbabbitt> ... but when combined with other issue, there's a reasonable argument syntax is a little confusing and we should rework how we expose random caching to authors<br>
&lt;kbabbitt> ... lot of discussion in thread, will hit final bit<br>
&lt;kbabbitt> ... rather than the caching options mapping directly to what effects they have on caching key<br>
&lt;kbabbitt> ... rephrase whole thing into defining a name for this random value<br>
&lt;kbabbitt> ... can specify a dashed-ident and now that's a named random value, same everyhwere<br>
&lt;kbabbitt> ... can then mix in additional information into that name to determine dynamicness<br>
&lt;kbabbitt> ... using keywords property, element, property-indexc<br>
&lt;kbabbitt> ... add an element identifier, property name, etc<br>
&lt;kbabbitt> ... making it more unique, less likely to be shared<br>
&lt;kbabbitt> ... consistent concept here for first arg, always defining name, names are easy for people to reason about<br>
&lt;kbabbitt> ... easier than inverted model of caching keys<br>
&lt;kbabbitt> ... do think this will work better for people<br>
&lt;kbabbitt> ... seems like it would be decent<br>
&lt;astearns> q+<br>
&lt;kbabbitt> ... usage in Chrome is still very low<br>
&lt;kbabbitt> ... think Safari is early or not quite shipped, okay with changing it<br>
&lt;kbabbitt> ... if people are okay with this, we can make edits and get browsers changed to this different model<br>
&lt;kbabbitt> q+<br>
&lt;kbabbitt> astearns: I like the idea of just supplying the name, making it the most shareable<br>
&lt;kbabbitt> ... wondering if we could just start with the ident and not worry about other parts until later<br>
&lt;kbabbitt> TabAtkins: can't ignore elements part<br>
&lt;kbabbitt> ... if only choices are max random different from everything or min random same everywhere<br>
&lt;kbabbitt> ... that kills the use case of share a value within an delement but different elem to elem<br>
&lt;kbabbitt> ... theoretically we could avoid prop and index stuff, doable by hand<br>
&lt;astearns> ack astearns<br>
&lt;kbabbitt> ... just a matter of forcing people to put those sorts of details in by hand<br>
&lt;kbabbitt> ... hurts some dynamic use cases especially as we get custom fns() rolled in<br>
&lt;kbabbitt> ... would be okay with droppoing those parts for now<br>
&lt;astearns> ack dbaron<br>
&lt;kbabbitt> ... elem part needs to be in there, core use case<br>
&lt;miriam> q+<br>
&lt;kbabbitt> dbaron: is plan that not change default behavior when none of the key sturff is specified?<br>
&lt;kbabbitt> TabAtkins: correct, nothing specified is max randomness<br>
&lt;kbabbitt> dbaron: so is another way to think about default bheavior... my mental model at this point is default behaviors, not specifying a name but are specifying per elem per prop per index?<br>
&lt;kbabbitt> TabAtkins: yes, another way to think about it is, if you don't specify anything you get a unique thing<br>
&lt;kbabbitt> dbaron: not quite unique because if you override with cascade you can get the same thing<br>
&lt;oriol> q+<br>
&lt;kbabbitt> TabAtkins: details are slightly differe,t but mental model is with no specified name you get unique name instead<br>
&lt;kbabbitt> dbaron: have a slightly different mental model<br>
&lt;fantasai> scribe+<br>
&lt;astearns> ack kbabbitt<br>
&lt;fantasai> kbabbitt: If we're talking about a name in this way, is this something we define with an at-rule instead of instantiating with a property value?<br>
&lt;fantasai> kbabbitt: Similar to supports conditions etc. Then have a defined name.<br>
&lt;fantasai> TabAtkins: Rejected that idea because it doesn't solve the problem.<br>
&lt;kbabbitt> TabAtkins: had to reject that idea becuse it doesn't solve problem<br>
&lt;kbabbitt> ... simplest use case could be global, others not<br>
&lt;fantasai> TabAtkins: Simplest use case could be global, but others can't.<br>
&lt;kbabbitt> ... e.g. per-element values can't be global<br>
&lt;kbabbitt> ... doesn't help in any meaningful way<br>
&lt;kbabbitt> ...; just introducing a level of indirection that doesn't gain anytrhing<br>
&lt;kbabbitt> ... if this was a complicated syntax thing we could offload elsewhere, there might be an argument but this doesn't reduce that<br>
&lt;kbabbitt> kbabbitt: ok<br>
&lt;astearns> ack fantasai<br>
&lt;Zakim> fantasai, you wanted to ask relationship to table in https://github.com/w3c/csswg-drafts/issues/13132#issuecomment-3562752018<br>
&lt;kbabbitt> fantasai: there was a comment from tim that was summarizing interpratations<br>
&lt;kbabbitt> ... wanted to check whether what you're proposing is same as what's in that table aside from keywords not having prefix<br>
&lt;kbabbitt> TabAtkins: yes<br>
&lt;kbabbitt> ... just shortened keywords but it does come down to identical to what tim was proposing<br>
&lt;kbabbitt> fantasai: he was repeating proposal, making sure he understood it<br>
&lt;astearns> ack miriam<br>
&lt;kbabbitt> miriam: hoping I understand correctly<br>
&lt;kbabbitt> ... a little confusion from me about when we're matching or sharing a value across elements taht are matched by the same rule<br>
&lt;kbabbitt> ... or when are we sharing more globally than that<br>
&lt;astearns> match-element?<br>
&lt;kbabbitt> ... does element-shared or a name just mean it's shared by all elems matched by that ru;e?<br>
&lt;kbabbitt> ... or are we talking about other elems matched by that rule<br>
&lt;kbabbitt> TabAtkins: rule it shows up in is not considered at all<br>
&lt;kbabbitt> ... arguments to be made that it's intuitive in someways but it's possible without applying a semantic to it<br>
&lt;kbabbitt> ... via style rule etvc<br>
&lt;kbabbitt> ... don't think tying its randomness to location in stylesheet is sufficiently useful and would often be a trap<br>
&lt;kbabbitt> ... so rule location has no bearing<br>
&lt;kbabbitt> ... things that matter are property it's used in, index in that property, element it's applied to<br>
&lt;dbaron> Tying randomness to rule location makes it hard to do things like "random color, but color-mix() it lighter on :hover"<br>
&lt;kbabbitt> ... proposal is supply a name and optionally mix in those identities to make it more unique<br>
&lt;kbabbitt> ... anything with same name shartes same value<br>
&lt;astearns> ack oriol<br>
&lt;kbabbitt> oriol: as I mentioned in issue, not liking the property-index keyword<br>
&lt;kbabbitt> ... to me it refers to index within property instead of mix of property + index<br>
&lt;kbabbitt> ... also TabAtkins mentioned that allowing a lone index keyword could be weird in practice<br>
&lt;kbabbitt> ... that's why we proposed to have keyword as mix of prop + index<br>
&lt;TabAtkins> (that is, Oriol prefers `random(--foo property index, 1, 10)` rather than `random(--foo property-index, 1, 10)`, which is fine for me0<br>
&lt;kbabbitt> ... guess that's right but from thoretical point of view, having index alone would be totally fine<br>
&lt;kbabbitt> ... would prefer to leave the door open to that and have this as 2 keywords<br>
&lt;kbabbitt> ... in grammar could require property to be present when specifying index<br>
&lt;kbabbitt> ... would at least be easier to generalize in the future if we find it useful<br>
&lt;kbabbitt> ... and meaning is clearer<br>
&lt;astearns> ack fantasai<br>
&lt;kbabbitt> fantasai: overall this makes sense<br>
&lt;kbabbitt> ... 2 things that seem strongly intuitive to people are, hjave no args be as random as possible and have a name be globally shared<br>
&lt;kbabbitt> ... this proposal hits those while also allowing other variations<br>
&lt;kbabbitt> ... lean toward keeping per- prefix, makes syntax clearer<br>
&lt;kbabbitt> TabAtkins: argument against that is, wheneve ryou have a relational word like that in keyword, it needs to be clear in context what it's in relation to<br>
&lt;kbabbitt> ... 2 opposite things I've seen people read these keywords as relation to<br>
&lt;kbabbitt> ... random per element or shared per element<br>
&lt;kbabbitt> ... after all the random function name is right there<br>
&lt;kbabbitt> ... but function of this argument is to control sharing<br>
&lt;kbabbitt> ... people in front of me interpreted in both ways<br>
&lt;kbabbitt> ... having that doesn't bias anything<br>
&lt;kbabbitt> ... not a strong preference, but preference is to not have that so we guide people to thinking about mixing it into the name<br>
&lt;kbabbitt> ... clearer semantic for what I want to communicate<br>
&lt;kbabbitt> ... without a relational word in there, more likely to guide authors to correct understanding<br>
&lt;kbabbitt> astearns: shall we take a resolution that supplying just an ident is going to make a globally shared random value?<br>
&lt;kbabbitt> TabAtkins: yes that's fine<br>
&lt;dbaron> +1<br>
&lt;kbabbitt> astearns: objections to bare ident case?<br>
&lt;TabAtkins> random(--foo, 1, 10) is "globally" shared<br>
&lt;kbabbitt> RESOLVED: Supplying just an ident to the random() function produces a value that is globally shared<br>
&lt;TabAtkins> (we'll resolve on the exact keywords later)<br>
&lt;kbabbitt> astearns: are we ready to make a decision about keywords or should we defer and move to regular meeting?:<br>
&lt;kbabbitt> TabAtkins: would be happy to resolve also happy to delay<br>
&lt;kbabbitt> astearns: I see a couple options<br>
&lt;kbabbitt> ... we could just have a keyword for matching element and others<br>
&lt;kbabbitt> ... or could specify all three keywords<br>
&lt;kbabbitt> ... not sure index and property keywords are justified by use cases yet<br>
&lt;kbabbitt> ... TabAtkins do you have a preference?<br>
&lt;kbabbitt> TabAtkins: yes, because those property and index are included in caching key in some cases<br>
&lt;kbabbitt> ... we should give option to authors to include them manually<br>
&lt;dbaron> +1 to ability to include them -- particularly with the mental model of this that I described :-)<br>
&lt;kbabbitt> ... not adding functionality, just a way to flip on in another case<br>
&lt;kbabbitt> ... think it's low cost an dpotentially useful<br>
&lt;kbabbitt> astearns: why don't we resolve to add property name and index keywords, names to be bikeshedded later<br>
&lt;kbabbitt> ... okay with you fantasai?<br>
&lt;kbabbitt> fantasai: yes would like to think about names but makes sense<br>
&lt;kbabbitt> astearns: any objections to resolving to add keywords for element, property, and index portions of key?<br>
&lt;kbabbitt> RESOLVED: add keywords for element, property, and index portions of key, open separate issue for exact names<br>
&lt;TabAtkins> happy to continue to have name discussions that we can potentially extra-resolve to, as long as it's relatively quick<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13132#issuecomment-3998898114 using your GitHub account


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

Received on Wednesday, 4 March 2026 17:06:31 UTC