Skip to content

Conversation

@romainmenke
Copy link
Contributor

@romainmenke romainmenke commented Apr 20, 2024

fixes : #2
see : https://drafts.csswg.org/css-syntax/#consume-number


I don't know the exact parameters, constraints and goals of your tokenizer.
So please let me know if it is not desired to match the specification to this degree.

@cdoublev
Copy link
Owner

cdoublev commented Apr 21, 2024

It should match the spec. However, imo, it is nonsense that order: 1.0 and order: 1e1 are invalid. Tab Atkins would probably like to fix one or both notations, see w3c/csswg-drafts#6471 (comment). But it is very low priority so I do not want to push for this change.

What is your opinion? (for the CSS language)

The existing doc is dreadful but has something about it actually. A consequence for <*-dimension> is noted, which refers to <n-dimension>, <ndash-dimension>, etc... which are used in subproductions of <an-b> in :nth-child() and co. For example, :nth-child(1e1) is valid whereas strict conformance only allows :nth-child(1). :nth-child(1e1n) is a bit weird so I would not mind restricting it to an "absolute" integer.

Another example is <zero>. For example, transform: rotate(0.0) is valid whereas strict conformance only allows transform: rotate(0). edit: actually the spec wants <number-token> whose value is 0 so 0e1, 0.0, etc are valid so this example is irrelevant.

@romainmenke
Copy link
Contributor Author

it is nonsense that order: 1.0 and order: 1e1 are invalid

I agree. This also leads to weird discontinuities when using math expressions.

10e3 vs. calc(10e3)

https://codepen.io/romainmenke/pen/GRLwLQy

Do you know if there already is a dedicated issue for specifically this aspect?
(Setting type integer when the actual value is an integer.)

@cdoublev
Copy link
Owner

cdoublev commented Apr 21, 2024

There are not any, I think, except the one I linked to in the previous comment and is only about the scientific notation.

I think <integer> only exists for some corner cases of the CSS grammar. There should be a default rounding behavior in properties like order, z-index, etc.

Another argument is that Number.isInteger(1.0) is truthy, probably like in most if not all progaming languages.

@romainmenke
Copy link
Contributor Author

I've filed a new issue here : w3c/csswg-drafts#10238

@cdoublev cdoublev force-pushed the master branch 5 times, most recently from 0d93d45 to 081aa6f Compare December 22, 2024 17:07
@cdoublev cdoublev force-pushed the master branch 2 times, most recently from 534796b to 65a6415 Compare July 2, 2025 05:32
@cdoublev cdoublev force-pushed the master branch 2 times, most recently from e9480e8 to 41341a4 Compare August 11, 2025 17:09
@cdoublev cdoublev force-pushed the master branch 2 times, most recently from 6511952 to 15b4236 Compare August 19, 2025 05:57
@cdoublev cdoublev force-pushed the master branch 3 times, most recently from c11d5c0 to b9c3c1b Compare January 9, 2026 10:45
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

Successfully merging this pull request may close these issues.

<number-token> does not distinguish between number and integer types.

2 participants