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 a serialization mode that mimics outerHTML #230

Closed
domenic opened this issue Jan 2, 2018 · 3 comments · Fixed by #383
Closed

Add a serialization mode that mimics outerHTML #230

domenic opened this issue Jan 2, 2018 · 3 comments · Fixed by #383

Comments

@domenic
Copy link

domenic commented Jan 2, 2018

That is, it should include the node itself.

Currently in jsdom we have to create a fake parent node with only one child node, the node we want to serialize, and then ask parse5 to serialize that.

@joeldenning
Copy link
Contributor

I've implemented this in #347. For anyone looking for a workaround, here's how you can serialize outerHTML without my new code:

import Serializer from 'parse5/lib/serializer/index.js'

function serializeOuterHTML() {
  const serializer = new Serializer()
  serializer._serializeElement(node)
  return serializer.html
}

@joeldenning
Copy link
Contributor

@fb55 following up from #347 (comment), what would you prefer the name of the new method be? Maybe serializeOuter?

@fb55
Copy link
Collaborator

fb55 commented Jan 13, 2022

serializeOuter works! We are about to land a major refactor (#362). Once that is done, I look forward to addressing this issue.

fb55 added a commit to parse5/parse5-fork that referenced this issue Jan 18, 2022
Fixes inikulin#230, inikulin#378

Uses the test case from inikulin#378, by @joeldenning

Co-Authored-By: Joel Denning <[email protected]>
fb55 added a commit to parse5/parse5-fork that referenced this issue Feb 7, 2022
Fixes inikulin#230, inikulin#378

Uses the test case from inikulin#378, by @joeldenning

Co-Authored-By: Joel Denning <[email protected]>
@fb55 fb55 linked a pull request Feb 7, 2022 that will close this issue
@fb55 fb55 closed this as completed in #383 Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants