-
Notifications
You must be signed in to change notification settings - Fork 715
[selectors-4] Clarity about whitespace between :nth-child()
's "of" and "S"
#8285
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
Comments
https://www.w3.org/TR/selectors-4/#grammar defines white space requirements for selectors, but you're right, it doesn't seem to indicate whether whitespace is required around |
The parsing is clear - |
Tests for this case added in web-platform-tests/wpt#37797 |
@fantasai @tabatkins Is there a reason to not require one? WebKit requires one, and although it'd be easy to change that, I think that'd be unfortunate. The fact that |
There's no particular reason to not require one, but the general policy across all of CSS is that whitespace is always optional, and I'm mildly opposed to adding one-off requirements for it unless there's a good reason; it just makes the language slightly less consistent. (And we probably can't add a general requirement for whitespace between tokens, because I suspect minifiers exist that take advantage of the current rules.) There's not really a "use-case" either way, it's just that comments are a guaranteed way to force a tokenization boundary without whitespace, so we usually reach for them when showing off the parsing. ^_^ |
…ld`/`:nth-last-child` https://bugs.webkit.org/show_bug.cgi?id=250353 rdar://104058693 Reviewed by Simon Fraser. As clarified by CSSWG editors in: w3c/csswg-drafts#8285 Tests: - LayoutTests/imported/w3c/web-platform-tests/css/selectors/nth-child-of-no-space-after-of.html - LayoutTests/imported/w3c/web-platform-tests/css/selectors/nth-last-child-of-no-space-after-of.html * LayoutTests/TestExpectations: * LayoutTests/fast/css/parsing-css-nth-child-of-3-expected.txt: * LayoutTests/fast/css/parsing-css-nth-child-of-3.html: * LayoutTests/fast/css/parsing-css-nth-last-child-of-3-expected.txt: * LayoutTests/fast/css/parsing-css-nth-last-child-of-3.html: * Source/WebCore/css/parser/CSSSelectorParser.cpp: (WebCore::CSSSelectorParser::consumePseudo): Canonical link: https://commits.webkit.org/258703@main
Should things like
:nth-child(1 of/* my comment */body)
or:nth-child(1 of.c)
parse?From CSS Syntax 3:
csswg-drafts/css-syntax-3/Overview.bs
Lines 3324 to 3328 in 7e7ead7
I was unable to find any mention of whitespace being required for
of S
in the CSS Selectors 4:nth-child()
pseudo-class or:nth-last-child()
pseudo-class sections.So should
<ident-token "of"> <complex-real-selector-list>
parse?If not, the CSS Selectors 4
:nth-child()
and:nth-last-child()
prose would probably benefit from clarification.If so, some examples would be nice.
The text was updated successfully, but these errors were encountered: