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
support :nth-child(2n + 1) syntax [whitespace around operator] #21
Conversation
Notice that the |
Hmm, I think there are some subtleties going on here that are a bit tricky. For example, this line handles one space around a Line 769 in 2a77b80
So I don't think the normalization is working as intended? For example, take a look at the state of |
I believe I initially misdiagnosed the situation, although the regex validation with So it seems to me that fixing the normalization might fix the root cause of this issue (with perhaps a few other small tweaks needed?) |
I've opened a PR with WPT to see if they'll add these selectors to their tests: web-platform-tests/wpt#12561 |
I added some more test cases which demonstrate why |
@jkillian the line you mentioned above:
is not part of a check on (an+b) parameters of structural pseudo-classes it is only a check targeting combinators, handling only one optional space before or after selectors and considering that the space character (0x20) is itself a combinator (one of the four). I don't think the problem is there. However the point you made is correct and the relevant fact I need to check is the reason white-space characters are not always coalesced to a single space. Thank you again for reviewing that part of the code. |
@jkillian 1390 // normalize selector but looking to it seems the "coalescing" part is missing. |
I added a naive solution where we combine all whitespace into a single space. However I think this is likely the wrong implementation. Since a selector like this: That said, all the test cases in |
@jkillian I will first say that the issue you brought up does spread beyond the pseudo-class parameters and needs some change also in the regular expressions currently used to cover other cases. Normalization of the input selector string is the key here. There are a couple of problems that must be solved to shape a final solution for this issue. The first is the one you mentioned, the input selector string normalization requires a clever RegExp.
Both files execute the same series of tests to check To run the WPT test in Since I am publishing the next version of
This RE will only change multiple white space chars not enclosed in single or double quotes, maybe I will need to add back-ticks "`" too but I need to review the specification and see what is required and what is not. At the moment the above RE works great for the task, so I am preparing the needed commits. I will surely give you the deserved credits for bringing my attention on this bug fix as soon as I commit the changes. Thank you again for your help with this. |
Hi @dperini, thank you for the reply again! Yes, I think it's best if we use your careful work to handle the whitespace issue. Once you have that in, we can add some test cases like the one in this PR to see if any further work is needed. If 2.1.0 is going to be released soon, we could wait until then to fix this bug - it might make things simpler overall. Your choice! (As a side comment, would you consider adding a section to your readme about the necessary tests that must be run to check changes to the codebase? Your information above is helpful and I think it might help people in the future to have the info in the readme.) |
Fixed more correctly by 9dfcc2a, so closing this out! |
Fixes #20
Not sure if this is the right way to fix and test this fix, but wanted to try and make a PR to help out! I wasn't sure if I was supposed to use the
WSP
variable or just\s
to indicate whitespace, so I tried to use the same methodology as the surrounding code.I also added a few test cases - I was a little confused about what file to add tests in, so let me know if this is the wrong place.
Also, feel free to discard my PR all together if it's easier to just do things yourself!