Giter Site home page Giter Site logo

Tree adapter for DOM about parse5 HOT 6 CLOSED

inikulin avatar inikulin commented on September 9, 2024
Tree adapter for DOM

from parse5.

Comments (6)

nrkn avatar nrkn commented on September 9, 2024 1

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:

https://github.com/nrkn/treeadapter-mapper

from parse5.

inikulin avatar inikulin commented on September 9, 2024

jsdom?

from parse5.

gagern avatar gagern commented on September 9, 2024

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?

from parse5.

inikulin avatar inikulin commented on September 9, 2024

Well, seems like I don't quite understand what you want. Can you illiustrate it via some code snippets, please?

from parse5.

gagern avatar gagern commented on September 9, 2024

What I had in mind was something like this:

var parser = new Parser(new DomTreeAdapter(new xmldom.DOMImplementation()));

where DomTreeAdapter would be a new class shipped with parse5, and its constructor argument could be any object satisfying the DOMImplementation specification. But I now had a closer look and realized that on the one hand, libxml-dom apparently doesn't offer such a DOM implementation class, so the number of users would be rather small.

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.

from parse5.

inikulin avatar inikulin commented on September 9, 2024

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.

from parse5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.