-
Notifications
You must be signed in to change notification settings - Fork 39
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
:scope pseudo-class fails for some XML documents with HTML-incompatible id #53
Comments
We have a related issue regarding scope in b-fuze/deno-dom#97. We have the following code that returns the correct output in the browser, but incorrect output when used with nwsapi. const doc = new DOMParser().parseFromString(
`
<div>
<div class=outer>
<div class=inner></div>
</div>
<div class=other-outer></div>
</div>
`,
"text/html",
);
const parent = doc.querySelector("div");
console.log(
[...parent.querySelectorAll(":scope > div")].map((d) => d.className),
); Outputs the following with in the browser: [ "outer", "other-outer" ] Whereas it outputs the following with nwsapi [ "outer", "inner", "other-outer" ] Which is also due to the fact that the |
@b-fuze current release of nwsapi produces correct output as you outlined above. |
I'm still seeing nwsapi fail on the leading digit, with a fresh clone of the project:
error:
Likely due to this identifier regex that disallows leading digits: https://github.com/dperini/nwsapi/blob/master/src/nwsapi.js#L596 edit: fix formatting |
:scope
fails to work with XML documents which have HTML-incompatible ids. Example:This works on Chrome. However, using nwsapi fails:
The failure stems from :scope pseudo-class being replaced with element references which then create a selector that is invalid since HTML id attributes can't start with numbers:
Uncaught DOMException: 'outer#1a inner' is not a valid selector
edit: hit enter too fast
The text was updated successfully, but these errors were encountered: