-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
Tree adapter for DOM #49
Comments
Adaptor for jsdom, xmldom, libxml-dom, … In case you wanted to suggest jsdom as an alternative: sure, it can provide similar functionality, but the fact that the latest version requires io.js makes me reluctant to use it. And parsing to jsdom just so you can import the node into some other DOM implementation you're working with doesn't look attractive either. On the other hand, another tree adaptor would be a fairly easy affair. Should I make this a pull request? |
Well, seems like I don't quite understand what you want. Can you illiustrate it via some code snippets, please? |
What I had in mind was something like this: var parser = new Parser(new DomTreeAdapter(new xmldom.DOMImplementation())); where On the other hand, parse5 does object creation significantly different from what the DOM specs envision, so the effort to make things work out would be considerable. In particular, one would have to know the name (and namespace) of the root element before creating the document, and one would have to pass the document as an adapter function argument whenever constructing new elements. Probably not worth the effort just now. I thought this would be simpler, thus my suggestion. Feel free to close if you don't want to pursue this either. |
DOM has a much more complicated connection with the HTML parser than this. I suggest you to keep an eye on JSDOM project, which is the most complete and spec-compliant pure-js DOM implementation at the moment. |
I had need of something like this https://github.com/nrkn/dom-treeadapter/ I'm not actually using it with parse5 though - I've adopted the parse5 TreeAdapter interface throughout another project and I'm using it to map between two different DOM structures. Here's the mapper I'm using: |
It would be nice if we could have an implementation-agnostic tree adaptor for DOM.
That way, one could use
parse5
to load the document, then use all the DOM manipulating tools out there to tweak the data, and finally serialize things again usingparse5
. Or just do one of parsing and serialization usingparse5
, the other with something different.The text was updated successfully, but these errors were encountered: