NEW 265276
Support CSS math functions on flexible lengths
https://bugs.webkit.org/show_bug.cgi?id=265276
Summary Support CSS math functions on flexible lengths
Roman Komarov
Reported 2023-11-23 02:17:22 PST
To reproduce, go to https://codepen.io/kizu/pen/RwvyyOg or try using `calc(1fr)` in `grid-template-columns`. The `calc(1fr)` is treated as invalid, but it should be valid, as per specs (see it for the `<flex>` type): https://drafts.csswg.org/css-values-4/#calc-type-checking and as clarified by the spec editors: https://github.com/w3c/csswg-drafts/issues/6989 > Definitely a bug; `fr` units should be math'able just fine. That note is, indeed, just observing that `fr` is not a `<length>` so `calc(1px + 1fr)` is invalid, but `calc(1fr / 3)` should be just fine. Curiously, no other browser did fix this yet. Chromium has a bug open from 2019: https://bugs.chromium.org/p/chromium/issues/detail?id=993136&q=calc%20fr&can=2 and I did not find one for Firefox, so I did open it: https://bugzilla.mozilla.org/show_bug.cgi?id=1866236
Attachments
Roman Komarov
Comment 1 2023-11-23 04:54:47 PST
I did open a PR adding WPT tests for this: https://github.com/web-platform-tests/wpt/pull/43322
Radar WebKit Bug Importer
Comment 2 2023-11-30 02:18:14 PST
Tim Nguyen (:ntim)
Comment 3 2025-01-22 07:49:05 PST
Sam, is this easy to do with the calc() rewrite you did?
Sam Weinig
Comment 4 2025-01-23 17:08:15 PST
I can't speak to why the initial codepen doesn't seem to work as the text in the codepen suggests it should (its not 50%) but calc() and fr units is fully supported. (I just don't understand the grid syntax at all so don't know if its correct. The WPT test added for this, https://wpt.fyi/results/css/css-grid/grid-definition/grid-support-flexible-lengths-001.html?label=experimental&label=master&aligned, seems to be passing in Safari.
Roman Komarov
Comment 5 2025-01-24 00:12:07 PST
The current WPT tests do not cover the case I mentioned — my wpt PR with the tests for this is still unmerged: https://github.com/web-platform-tests/wpt/pull/43322
Note You need to log in before you can comment on or make changes to this bug.