-
Notifications
You must be signed in to change notification settings - Fork 91
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
Error when using root option in jsdom #65
Comments
I tried a few css selector generators, listed here: <https://github.com/fczbkk/css-selector-generator-benchmark> - css-selector-generator failed when a root (= scope) is passed; see issue <fczbkk/css-selector-generator#65>. - using @mdev/finder instead gave syntax errors due to ‘export’ token. (perhaps because we don’t transpile dependencies; worth considering?) - optimal-select seemed to work; whatever works is good enough for now. I made describeCss accept an Element, not a Range, for its scope and target, as Ranges make little sense for a CssSelector; I figured we may want to change this in the matcher too, and perhaps more widely.
I can confirm this behaviour with Chrome. What my tests found when a root element is provided :
|
This issue was not specific to JsDom. It was caused by attempting to test a descendant selector candidate which is direct descendant of root element (which itself has no selector). It should be fixed now. Please update to |
@Treora Regarding other problems you mentioned in your report: The The fallback selector ignores the root defined in the options, because that is the only way it can produce reliable and unique selector. It needs to start with the |
@Treora By the way, check out these instructions on how to add external code (e.g. library) to JsDom. I think it will help you with issues like missing global properties (e.g. |
Hi @fczbkk , Still have issue. I checked versions, and it appears that we are in 3.4.0 and not 3.2.1. Is this ok ? I forced update anyway, and issue still occurs. You can test it here with those elements : |
@lilacdev Can you please open a standalone issue for this and include specific instructions how to replicate this problem? Even better, if you could create a minimal isolated test case. Thank you. |
Of course, I was writing piece of code to reproduce it :). |
In the test case below, things work fine until I supply the
root
option. I have not tried whether the same problem occurs in a browser.This fails with:
Also, when using some other elements as root, it returns without errors, but the root seems to have been ignored:
Both of the above return the same value:
':root > :nth-child(2) > :nth-child(1) > :nth-child(2) > :nth-child(1)'
The text was updated successfully, but these errors were encountered: