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

Preserve unit for some 0 values #10

Open
iamvdo opened this issue Jun 30, 2014 · 6 comments
Open

Preserve unit for some 0 values #10

iamvdo opened this issue Jun 30, 2014 · 6 comments

Comments

@iamvdo
Copy link

iamvdo commented Jun 30, 2014

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?

@thierryk
Copy link

thierryk commented Jul 1, 2014

As far as I know, 0 can be unit-less only for 'length' values.
time, degree, etc. need unit.

@hail2u
Copy link

hail2u commented Jul 3, 2014

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.

@iamvdo
Copy link
Author

iamvdo commented Jul 3, 2014

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. :)

@thierryk
Copy link

thierryk commented Jul 4, 2014

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.

@stoyan
Copy link
Owner

stoyan commented Jul 5, 2014

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

@stoyan
Copy link
Owner

stoyan commented Jul 5, 2014

btw, http://dabblet.com/gist/3746116 looks good in FF 30 Mac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants