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
Proposal: getHTML() for Document interface #10280
Comments
/cc @mfreed7 |
It seems reasonable, but do we have use cases for this? I think we mainly added |
One case that I can think of is a cobrowsing functionality where the current pages DOM is serialised sent across the wire and reconstructed on the other side. Though in practice those situations might actually use something like a tree walker to serialise to their own format. |
It would be a nice HTML equivalent of |
If there's a use case, this is relatively trivial to implement, so I'm supportive. |
@domenic you mentioned you might have a use case for this in jsdom. I know that isn't actually using the platform it's recreating it but the use case might transfer? Edit: Here's the method https://github.com/jsdom/jsdom?tab=readme-ov-file#serializing-the-document-with-serialize |
What problem are you trying to solve?
There's currently no way to serialise a document object, that includes shadow roots.
What solutions exist today?
document.documentElement.outerHTML
is the closest we have but it won't serialize shadow roots, and it wont serialize the DOCTYPE node either.How would you solve it?
Define a new document.getHTML() function that would return a string such as
<!DOCTYPE html><html><head><title>Title</title></head><body><p>Contents</p></body>
Anything else?
No response
The text was updated successfully, but these errors were encountered: