Re: [csswg-drafts] [css-transitions] Transition to height (or width) "auto" (#626)

No.

In terms of the spec (defining that you can't do it), you can't because `calc-size()` is not defined to be a math function that's valid inside of `calc()`.  It's defined as a separate toplevel production (`<calc-size>`) that needs to be specifically allowed by each property that accepts it.  The only other place that accepts it is that it is accepted recursively as the *basis* (but not as the *calculation*).

In terms of rationale (why shouldn't it be allowed), it's because many layout algorithms in CSS depend not just on the mathematical values of these properties but also have conditionals that branch on what are essentially type checks on the value.  This alternative is a bit less general than allowing full `calc()` math on intrinsic sizing keywords, but avoids the need to go and rewrite a bunch of existing layout algorithms (tables, flex, grid, and I think also multicol) to avoid branches.  This rationale is discussed a bit in the section on [Allowing intrinsic sizing keywords inside of calc()](https://github.com/dbaron/csswg-drafts/blob/calc-size-explainer/css-values-5/calc-size-explainer.md#allowing-intrinsic-sizing-keywords-inside-of-calc) in the explainer (a subsection of "Considered alternatives"), and also the following paragraph from earlier in the explainer:

> In other words, when a CSS-based layout algorithm (for example, block layout, flex layout, grid layout, table layout, or multicolumn layout) has something that in pseudocode would be expressed as "if the value is a percentage" or "if the value is the fit-content keyword", then that pseudocode now examines the basis of any calc-size() value. However, when the layout algorithm needs the mathematical value resulting from the value, then the calculation is used.

-- 
GitHub Notification of comment by dbaron
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/626#issuecomment-2121525106 using your GitHub account


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

Received on Tuesday, 21 May 2024 01:20:12 UTC