Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-values-4] How to serialize calc(100% - 100% + 1em) at computed-value time #3806

Closed
TalbotG opened this issue Apr 4, 2019 · 5 comments · Fixed by #3811
Closed

[css-values-4] How to serialize calc(100% - 100% + 1em) at computed-value time #3806

TalbotG opened this issue Apr 4, 2019 · 5 comments · Fixed by #3811
Labels
css-values-4 Current Work

Comments

@TalbotG
Copy link
Collaborator

TalbotG commented Apr 4, 2019

§10.7. Computed Value states:

calc(100% - 100% + 1em) resolves to calc(1em + 0%), not to 1em

https://drafts.csswg.org/css-values-4/#calc-computed-value

but shouldn't that be instead:

"calc(100% - 100% + 1em) resolves to calc(0% + 16px), not to 16px", assuming 1em = 16px ?
Either this is the case or last parg of Example 35 (following below) misleads and creates confusion.

A value like calc(20px + 2em) would serialize as calc(2em + 20px) as a specified value (maintaining both units as they’re incompatible at specified-value time, but sorting them alphabetically), or as something like 52px as a computed value (em values are converted to absolute lengths at computed-value time, so assuming 1em = 16px, they combine into 52px, which then drops the calc() wrapper.)

@TalbotG
Copy link
Collaborator Author

TalbotG commented Apr 5, 2019

http://www.gtalbot.org/BrowserBugsSection/CSS3Values/getComputedStyle-calc-background-position-percent-012.html

Firefox 68 and Epiphany Technological Preview 3.31.90-8061c1929 (WebKitGTK 2.24.0) pass this test .

Chromium 73.0.3683.75 and Chromium 75.0.3753.0 return "16px 50%" instead of the expected "calc(0% + 16px) 50%" .

@TalbotG
Copy link
Collaborator Author

TalbotG commented Apr 5, 2019

A note in § 10.9 Serialization states:

(...) em and px are obviously different at specified-value time, but at computed-value time they’re both absolutized to px.

https://drafts.csswg.org/css-values-4/#calc-serialize
https://www.w3.org/TR/css-values-4/#calc-serialize

@tabatkins
Copy link
Member

You are correct, that example is wrong and should be showing a px result. The em part isn't important, so I'll just change it to a px value so I don't need to add additional text implying an em->px conversion ratio.

@TalbotG
Copy link
Collaborator Author

TalbotG commented Apr 6, 2019

Don't you need to also change the sorting order of terms too? Percentage precedes dimension.

ewilligers pushed a commit to ewilligers/csswg-drafts that referenced this issue Apr 6, 2019
@ewilligers
Copy link
Contributor

Percentage first. PR uploaded.

@ewilligers ewilligers reopened this Apr 6, 2019
@fantasai fantasai added the css-values-4 Current Work label Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-values-4 Current Work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants