-
Notifications
You must be signed in to change notification settings - Fork 51
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
"combinators" found in nth-child
expressions
#14
Comments
This is a tradeoff between the parser being generic enough to support custom pseudo element syntax, whilst also being specific enough to understand common CSS grammar such as the combinator. Are we sure we are not just duplicating the discussion in #13? If we add the detection of this case to the parser we have to go down the road of differentiating between pseudo element syntax. The current approach prefers that the user performs her own checking for these expressions, which I prefer as it means that the parser is faster. |
Yeah, I see the flexibility argument. However, this is faulty parsing of valid CSS --- I'm guess I'm not going to agree that that's not a problem. Would it be sufficient to say that anything wrapped in parentheses is an "expression" and therefore plays by different rules? Maybe you don't go to the trouble of really parsing |
The main use case is in pseudo elements that take a selector list, for example the negation selector: h1:not(.main-title, .article-title) {} |
Makes sense. But that does mean you're privileging If user was told that their pseudo-selector *Please understand I'm not trying to be pushy, just trying to troubleshoot with you :) |
Yes, the h1:not(h2:not(h3:not(h4:not(h5:not(h6))))) {} As I remarked earlier, this is a tradeoff. I wrote it like this because I thought that it was a good idea to allow people to map over nested pseudo selectors easily. If it is not done inside the parser, we must write some user-land code to evaluate the result of that expression through another run of the parser, which I felt was a bit wasteful. |
Ok. I'm unconvinced that returning an inaccurate AST on valid selectors is worth this, but I'll close the issue. |
Actually, I think both approaches are valid. If I had implemented your method in the first place (which was one of the very first considerations) then I may have had someone asking of me the way I have implemented it now. Would you be happier with a flag for not parsing pseudo selector parameters? |
I do think that would be a good addition. Either way there should probably be some note in the README about the issue; and it would look better if rather than just having to state "The parser will return an inaccurate AST if input CSS contains |
Let's say I will accept a PR for an optional flag for the parser to not parse pseudo parameters. I can potentially handle this myself but it would be lower down on the priority list. |
FYI:
See 1 |
@davidtheclark I'm currently working on a selector parser that supports plugins for function calls, so it can differentiate between a call to |
Thanks for the heads up, @clentfort. |
the The general syntax is I suggest that any psuedo with parens starting with I think we should add a
|
Another
nth-child
problem ...Given the selector
.foo:nth-child(2n + 1)
, the parser thinks that plus sign is a combinator.Given the selector
.foo:nth-child(2n - 1)
, the parser thinks the spaces around the minus signs are combinators.The text was updated successfully, but these errors were encountered: