Preserve unit for some 0 values
There are bugs with some unitless 0.
For example, here are two examples with times (check in Chrome and Firefox to see differences)
http://jsbin.com/ledeb/2/edit http://dabblet.com/gist/3746116
I think sand ms unit should be preserved, even with 0?
As far as I know, 0 can be unit-less only for 'length' values.
time, degree, etc. need unit.
In CSS Values and Units Module Level 3, 8.3. Attribute References: ‘attr()’, ‘length’ ‘angle’ ‘time’ ‘frequency’:
The default is ‘0’ in the relevant units, or else the property's minimum value if ‘0’ in the relevant units is not valid for the property.
and:
(e.g. positive lengths or angles from 0 to 90deg)
I think the spec suggests unit-less is not only for length unit.
The spec is pretty clear in 4.3.2 : (http://www.w3.org/TR/CSS2/syndata.html#values)
for zero lengths the unit identifier is optional
It doesn't appear anytime else in the whole spec.
I don't say that it won't work in browser. Just that it may be invalid to remove these units. :)
Same in CSS3: 5. Distance Units: the <length> type
Lengths refer to distance measurements and are denoted by <length> in the property definitions. A length is a dimension. However, for zero lengths the unit identifier is optional (i.e. can be syntactically represented as the <number> ‘0’).
I may be wrong, but this:
A length is a dimension. However, for zero lengths the unit identifier is optional (i.e. can be syntactically represented as the <number> ‘0’).
seems to suggest that "even if length is a dimension, the unit identifier is optional". Meaning it is not the case for other dimensions. After all, 6. Other Units (angles, times, frequencies, resolutions) does not mention anything about using 0 without a unit identifier.
Fwiw, I did some digging and I found this article about <angle> on MDN where it says:
Note: 0 is not a valid angle value.
hm, yes, I came across the MDN article so 0 angkles are preserved: https://github.com/stoyan/cssshrink/blob/master/lib/visitors/zero-dimensions.js#L1
I'll add time always be 0s.
Not sure what to do about the others, some browser testing is in order
btw, http://dabblet.com/gist/3746116 looks good in FF 30 Mac