Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

<!DOCTYPE html> is stripped out #20

Closed
nemtsov opened this issue Dec 17, 2016 · 3 comments
Closed

<!DOCTYPE html> is stripped out #20

nemtsov opened this issue Dec 17, 2016 · 3 comments
Labels

Comments

@nemtsov
Copy link

nemtsov commented Dec 17, 2016

From examples/generic-simple:

input:

<!DOCTYPE html>
<html>
  <head>
    <title>Generic &amp; Simple Prerendering Demo</title>
  </head>
  <body>
    <input id="new-todo" placeholder="New todo">
    <div id="todos"></div>
    <script src="main.js"></script>
  </body>
</html>

output:

<html><head>
    <title>Generic &amp; Simple Prerendering Demo</title>
  </head>
  <body>
    <input id="new-todo" placeholder="New todo">
    <div id="todos"><ul><li class="item">Do the dishes <button class="remove-todo" data-index="0">X</button></li><li class="item">Make the bed <button class="remove-todo" data-index="1">X</button></li><li class="item">Take out the trash <button class="remove-todo" data-index="2">X</button></li></ul></div>
    <script src="main.js"></script>
  

</body></html>

Note that the <!DOCTYPE html> is stripped out.
It is important that the doctype is preserved, as it affects page rendering.

@nemtsov nemtsov changed the title <!doctype html> is stripped out <!DOCTYPE html> is stripped out Dec 17, 2016
@qgustavor
Copy link

qgustavor commented Dec 17, 2016

I was just going to post this issue, but I'm one hour delayed... Seems the problem is on this line: return document.documentElement.outerHTML. Isn't hard to get the doctype and fix that.

Edit: how about this? (I just tested here, it's working)

var html = page.evaluate(function () {
  const doctype = new XMLSerializer().serializeToString(document.doctype)
  const outerHTML = document.documentElement.outerHTML
  return doctype + outerHTML
})

@chrisvfritz
Copy link
Owner

Good catch! I'll add this fix as soon as I can given the holidays.

@chrisvfritz
Copy link
Owner

Fixed in the 2.0 release. 🎉

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants