getComputedStyle() of "flex-basis" should return "10%" if the style sets to "calc(0px + 10%)"

NEW
Unassigned

Status

()

P3
normal
2 years ago
a year ago

People

(Reporter: daisuke, Unassigned)

Tracking

(Depends on: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

2 years ago
Created attachment 8776860 [details]
getComputedStyle.html

I attach the test html.
For now, that returns "calc(0px + 10%)".
Just a few notes, the spec doesn't actually say this but this is what Chrome does and it seems sensible to spec.

At the moment we seem to do:

calc(300px + 0%) -> 300px
BUT
calc(0px + 10%) -> calc(0px + 10%)

I'm not sure what the reasoning for this is (I looked up the changeset and bug and there was no explanation) but it seems like we should either always simplify or never.

Updated

2 years ago
Priority: -- → P3
(In reply to Brian Birtles (:birtles) from comment #1)
> Just a few notes, the spec doesn't actually say this but this is what Chrome
> does and it seems sensible to spec.
> 
> At the moment we seem to do:
> 
> calc(300px + 0%) -> 300px
> BUT
> calc(0px + 10%) -> calc(0px + 10%)

There is actually some spec text for this[1] although it as marked as being "under discussion".

As it currently stands it would suggest we preserve zero values so that, `the calc() doesn’t suddenly "change shape" in the middle of a transition when one of the values happens to have a zero value temporarily.'

I don't really understand the concern there but in any case, Gecko's behavior doesn't match that either so something will need to change here.

[1] https://drafts.csswg.org/css-values/#calc-serialize
You need to log in before you can comment on or make changes to this bug.