fgnass / domino

Server-side DOM implementation based on Mozilla's dom.js
BSD 2-Clause "Simplified" License
768 stars 120 forks source link

Implement DOMParser interface #137

Open penguinput opened 5 years ago

penguinput commented 5 years ago

This implementation seems to work correctly when the content type is set to text/html, however the XML types fall through the HTMLParser since there's no XMLSerializer interface.

The tests for the text/html type are passing, except the baseURI one, since its getter is not yet implemented in the lib/Node.js file. If, in the future, the XMLSerializer interface is implemented I think it should be easy to add the missing logic.

Lastly: I'm not sure if the DOMParser interface should be exposed the way I did. It needs to access the active document address and I didn't find any other way to make it work. Maybe, by logic, it should go into the lib/impl.js file?


Edit:

At the end I decided to definitely throw on the not-yet-implemented XML types to avoid misleading behavior with the HTMLParser fallback (case sensitivity to name one). Still, I'm not really sure I exposed the DOMParser interface the proper way.