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

Consider following https://w3c.github.io/DOM-Parsing/#xml-serialization #8

Open
domenic opened this issue Jul 2, 2016 · 4 comments

Comments

@domenic
Copy link

domenic commented Jul 2, 2016

I'm looking for something that follows the spec browsers use so that I can use it in jsdom. Any thoughts on adding a mode that follows that algorithm more exactly?

@cburgmer
Copy link
Owner

cburgmer commented Jul 3, 2016

Hey, as somewhat hinted at in the README, I'm happy to make this thing more standards compliant. We might only need to retain some specifics, for rasterizeHTML.js to force HTML to XML conversion, but hopefully this will get down to being a xmlns override only + the removal of characters invalid in XML. Both could be made optional behaviour.

After a quick glimpse into the linked document, it looks like e.g. the serialisation for empty nodes needs an overhaul. And most likely there's going to be more.

Let me know what you need. Happy to give access to the repo.

@cburgmer
Copy link
Owner

cburgmer commented Jul 3, 2016

Btw, tests/BrowserCompatibilityRunner.html shows how the test cases align with what a browser would currently serialise. Gives a bit of an overview on what's different right now.

@lehni
Copy link

lehni commented Jul 6, 2016

@cburgmer @domenic I'm happy to help out also if I can, as we could need this in https://github.com/paperjs/paper.js

@tommedema
Copy link

Indeed xmlserializer seems to behave differently from browsers.

In a browser you can do:

const doctypeStr = new XMLSerializer().serializeToString(document.doctype);

while xmlserializer.serializeToString(document.doctype) results in:

TypeError: Cannot read property 'replace' of undefined
      at removeInvalidCharacters (node_modules/xmlserializer/xmlserializer.js:13:24)
      at Object.serializeToString (node_modules/xmlserializer/xmlserializer.js:126:20)
      at XMLSerializer.serializeToString (test/helper.js:57:29)

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

4 participants