W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2012

Re: [whatwg] Proposal for window.DocumentType.prototype.toString

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Mon, 29 Oct 2012 21:17:45 -0400
Message-ID: <508F2AB9.6000408@mit.edu>
To: whatwg@lists.whatwg.org
On 10/29/12 8:58 PM, Johan Sundström wrote:
> Serializing a complete HTML document DOM to a string is surprisingly
> hard in javascript.

I thought there were plans to put innerHTML on Document.  Did that go 
nowhere?

> As a fairly seasoned javascript hacker I figured
> this might do it:
>
>    document.doctype + document.documentElement.outerHTML

This seems lossy in many cases (most obviously: when the HTML uses 
conditional comments, though there are also various XHTML-specific issues).

> The most useful implementation would IMO be a native one
> that reproducing the doctype, as it was formatted in the source
> document.

That might be worth doing independent of the serialization issue.

-Boris
Received on Tuesday, 30 October 2012 01:18:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:11 GMT