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
Can xmldom support querySelectorAll? #92
Comments
https://www.npmjs.com/package/jsdom Use jsdom to solve the problem |
In the current state of this library, I would consider it out of reach, potentially even for v1.0 since
Maybe it can be achieved by adding some dependency, but this also comes with an additional maintenance cost, since it currently doesn't have production dependencies. So I think going for something like jsdom for that is a valid approach. This is of course just my personal opinion. |
I'd say the project should stay zero-dependencies. I'd be happy if if there were a |
For those who can't use JSDOM, I was able to get my use case working using the query-selector package. Your mileage may vary. import querySelector from "query-selector";
import { DOMParser } from "xmldom";
const doc = new DOMParser().parseFromString("<foo />", "text/xml");
const documentPrototype = Object.getPrototypeOf(doc);
documentPrototype.querySelectorAll = function querySelectorAll(selector) {
return querySelector(selector, this);
}; |
I think this issue could already be closed. What do you think @brodybits ? |
It would be awesome if we could get this documented. @karfau I may need a few days to get to the other recent threads on |
I think it's a good idea to document this decision. It's also related to #176 |
Another round of trying to argue for closing this issue:
Feel free to reopen, but please provide some arguments/proposals of how to solve the above points. |
I feel like posting my use case. I am using the My app should be able to run the same code both in the browser and outside of it, hence my requirements. Thanks anyway for clarifying this and for this library. |
@atava thx for adding your use case. There is thing I want to point out/clarify: I think it should be technically possible to create a But this is not something that the xmldom maintainers will do, since right now xmldom has quite some differences in behavior compared to the implementation of browsers, and with the current amount of resources it will take quite a while to align it, so it's most likely not a good idea. So using the |
@karfau Thanks, and sorry for replying so late. To further elaborate on this, I would need an isomorphic
Thanks for clarifying that this library could not and would not add a 1:1 implementation of |
Just found out about https://github.com/fb55/css-what which might be helpful if somebody wants to implement a node visitor based on it (outside of this repository). |
It would be great if If In order to have the same code for Node.js and browsers. Some examples: let html = `
<style>a {color: red};</style>
<div style="display: none">qwe</div>
<div class="foo">asd <a href="#">[link]</a></div>
</div>`;
let doc = new DOMParser().parseFromString(html, "text/html");
|
jsdom' Also they are not interested in this issue. |
There will not be any support for And people already suggested above how this feature can be "added" on the fly using an external dependency. But for adding |
support querySelectorAll
TypeError: document.querySelectorAll is not a function
The text was updated successfully, but these errors were encountered: