Skip to content
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

Add support for DOM standard interfaces #684

Open
mindplay-dk opened this issue Oct 6, 2021 · 2 comments
Open

Add support for DOM standard interfaces #684

mindplay-dk opened this issue Oct 6, 2021 · 2 comments

Comments

@mindplay-dk
Copy link

This is a great library and it's already been extremely useful for a number of things. 🙂👍

Is there a design reason why the APIs deviate from the DOM standard, or is it just the way it ended up?

I won't go into too much detail here, but the fact that property names and functions have different names and types is extremely disruptive, if you're trying to integrate with existing code and tests, etc. - and especially in TypeScript.

To be clear, I'm not asking for or expecting a full implementation of the DOM standard - I'm not asking for any new features per se. But even code that requires a subset of a DOM interface does not immediately work without remapping the node model to something compatible first.

Would you be at all open to changing this? I might be able to help. (It would be a break change, of course.)

(I apologize if this has already been asked and answered - it seems unlikely I could be the first person to ask, but I did search your issues and, to my surprise, I didn't find anything.)

@fb55
Copy link
Owner

fb55 commented Nov 11, 2021

The DOM structure was inherited from the original node-htmlparser project. There are aliases available for a lot of the DOM names, eg. tagName will get a node's tag name; the same is true for eg. childNodes, nodeType and attributes.

I don't want to introduce any breaking changes here, as there is a lot of code depending on this library. But if there are any aliases you'd like to see, feel free to add them to the domhandler module.

@fb55 fb55 transferred this issue from fb55/htmlparser2 Nov 11, 2021
@fb55
Copy link
Owner

fb55 commented Nov 11, 2021

Transferred to domhandler, as this is more appropriate here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants