Open Bug 1836588 (css-random) Opened 2 years ago Updated 8 days ago

Implement CSS random() function

Categories

(Core :: CSS Parsing and Computation, enhancement)

enhancement

Tracking

()

People

(Reporter: canadahonk, Unassigned)

References

(Depends on 3 open bugs, Blocks 7 open bugs, )

Details

(Keywords: web-feature)

User Story

web-feature: random-function

Implement the CSS random() function defined by CSS Values and Units Module Level 5.

No WPT tests exist currently (they should be added if implemented by us first). Not implemented or shipped by any engine yet.

Standards position: https://github.com/mozilla/standards-positions/issues/809

The standards position is currently negative so this likely won't be shipped or (internally) worked on (anytime soon at least). See also spec issue: https://github.com/w3c/csswg-drafts/issues/2826

The negative position on random() is unfortunate to hear. Over the past 10 years many SASS users have gotten use to using the math.random() module: https://sass-lang.com/documentation/modules/math/#random. Not having this in CSS proper could be a reason for people to not return to vanilla CSS.

The standards position is now positive and random()+random-item() has been added to the specification: https://www.w3.org/TR/css-values-5/#randomness
The WebKit engineers have started contributing WPT's, so they are probably working on implementing it: https://github.com/web-platform-tests/wpt/pull/50073

Blocks: 2017269
Blocks: 2016731
Duplicate of this bug: 2019274
Alias: css-random

When we get to implement this, we need to make sure to not just perma-leak all random values. Just using a rng seeded with the relevant key hashes instead would do, probably...

Blocks: 2025095
Depends on: 2031432
Depends on: 2031924
Depends on: 2034341
User Story: (updated)
Keywords: web-feature
You need to log in before you can comment on or make changes to this bug.