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

add number types #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

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