-
Notifications
You must be signed in to change notification settings - Fork 689
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-5] Should ident() accept <number> and <dimension>? #11551
Comments
Floating point is a concern especially with different architectures/languages/platforms. |
AFAIK dots are not allowed in |
Dots aren't allowed literally in a custom ident, but you can escape any character into one. That said, that is an excellent argument against this. (It just means that when we do the |
Can we get a WG resolution before closing this? I think it makes sense to exclude
So it seems reasonable to just round |
As the author of the issue, I'm allowed to withdraw my own comments without a WG resolution. ^_^
This just works already. You'll get a 3, because CSS auto-rounds math functions when used an an
We purposely don't do that rounding on numeric literals, because it's virtually guaranteed to be a mistake to write a non-integer where an integer is expected. We shouldn't break with our general tradition here. |
Discussed this with @tabatkins and @LeaVerou in person over lunch. We agreed to close no change because of the following, as Tab explained:
Worst-case, authors can choose to wrap things in |
Currently, the ident() function is defined to accept
<string> | <integer> | <ident>
, and serializes these before concatenating them.This means that
ident("foo" 1)
is valid (producing the identfoo1
), butident("foo" 1.2)
isn't, andident("foo" calc(1.2))
producesfoo1
. That seems odd.Is there a good reason to exclude
<number>
, and with that,<dimension>
? The serialization for numbers is inherently a bit less predictable, of course, due to floating-point, but in common cases it should do what the author expected. (Especially with CSS's "no more than 6 digits after the decimal point", so we avoid things like JS's.1 + .2
yielding0.30000000000000004
.)The text was updated successfully, but these errors were encountered: