| Summary: | min() function sometimes returns larger of two values instead of smaller, depending on the units used | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Brandon McConnell <brandon> | ||||
| Component: | CSS | Assignee: | Nikos Mouchtaris <nmouchtaris> | ||||
| Status: | NEW --- | ||||||
| Severity: | Major | CC: | obrufau, rbuis, rego, simon.fraser, webkit-bug-importer, zalan, zsun | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | WebKit Nightly Build | ||||||
| Hardware: | Mac (Intel) | ||||||
| OS: | macOS 11 | ||||||
| Attachments: |
|
||||||
|
Description
Brandon McConnell
2021-10-27 21:58:22 PDT
There is probably a bug indeed, but more complex that min() returning the maximum by mistake. Note that `width: min(100%, 100vw);` and `width: 100vw; max-width: 100%;` are not completely equivalent. During intrinsic sizing, if the percentages are cyclic then the former should be treated as `width: auto`, and the latter as `width: 100vw; max-width: none`. https://www.w3.org/TR/css-sizing/#cyclic-percentage-contribution Yes, I understand that `min()` takes the lowest value from a set of values, regardless of order. However, in this example, the `min()` function does in fact take the larger of the two values instead of the smaller. Manually evaluating `width: 100%` vs. `width: 100vw`, it can be observed that `width: 100vw` is the smaller of the two on mobile, yet when switching from `width: 100vw` to `width: min(100%, 100vw);`, the overall width of the element expands to the computed/intrinsic width of `100%` rather than the smaller width of `100vw`. Yes, I understand that `min()` takes the lowest value from a set of values, regardless of order. However, in this example, the `min()` function does in fact take the larger of the two values instead of the smaller. Manually evaluating `width: 100%` vs. `width: 100vw`, it can be observed that `width: 100vw` is the smaller of the two on mobile, yet when switching from `width: 100vw` to `width: min(100%, 100vw);`, the overall width of the element expands to the computed/intrinsic width of `100%` rather than the smaller width of `100vw`. |