-
Notifications
You must be signed in to change notification settings - Fork 757
[css-selectors-5]: move from :heading(<An+B>#) to :heading(<integer>#) #12634
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-selectors-5]: move from :heading(<An+B>#) to :heading(<integer>#) #12634
Conversation
selectors-5/Overview.bs
Outdated
|
|
||
| <pre class=prod> | ||
| :heading() = :heading( <<An+B>># ) | ||
| :heading() = :heading( <integer># ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<integer> would allow things like calc() in here. This probably only wants to permit literal integers? IDK, maybe calculations on env vars could be useful.
Though... I don't think CSS has an "integer literal" type anyway. Just a <number-token> one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? https://drafts.csswg.org/css-values-4/#integers doesn't seem to suggest that, instead saying it's a subset of <number-token>.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the important phrase there is "When written literally". It's not super clear in that phrasing, but you can definitely use calc() for other things that take <integer>, for example z-index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure calc() isn't allowed inside of selectors but I cannot find the relevant prose in spec to say where calc() is allowed.
Perhaps @tabatkins can point us in the right direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we've previously had a situation where a numeric type is allowed in a selector, though I might have missed that. I'm definitely nit-picking on technicalities here. 😅 But yeah Tab will know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess calc() is supported for the <length> of a media query (although not a selector, it demonstrates that calc() has support outside of declaration values).
Perhaps I can update the spec prose here to explicitly call out that only literal <integer> values are allowed and calc() would result in a parse error? I can also update the tests to reflect this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://drafts.csswg.org/css-values-4/#math says
A math function represents a numeric value, one of:
...
- <integer>
[...] and can be used wherever such a value would be valid.
Are arguments to functional selectors "values"? It's not super-clear to me if they should apply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, selectors are kinda a weird space here. As we add more "generic" value-handling functions (like ident()), we'll have to make a general decision on whether they're allowed in places like a rule's selector. I lean towards disallowing, matching how An+B only allows literal ints.
So I guess, just to be clear, I recommend using <number-token>, with prose specifying that the token's type flag has to be "integer", a la the an+b definition.
(Looking at this, I just realized we have two competing definitions of <integer>, one from Syntax and one from Values, which have different definitions. That's not great. I should scope the Syntax definitions there to be specifically for an+b.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted for <level> as a discrete type just for a little more clarity. Hopefully this works, happy to use <number-token> instead though.
|
Nit: The commit message and title misspell "heading" as "headng". Sebastian |
bbdca2e to
7856852
Compare
7856852 to
77149b6
Compare
77149b6 to
5300992
Compare
Closes #12599