[PATCH 5 of 6 V2] hgweb: add docFromHTML javascript function

Laurens Holst laurens.nospam at grauw.nl
Tue Aug 20 11:41:32 CDT 2013


Op 18-08-13 00:29, Alexander Plavin schreef:
> # HG changeset patch
> # User Alexander Plavin <alexander at plav.in>
> # Date 1376739340 -14400
> #      Sat Aug 17 15:35:40 2013 +0400
> # Node ID 4b97b9c7034ef5d561021ce6f1f34a2f89764e7c
> # Parent  0258e9b301d3d93c820ea640fdc3d19874d01656
> hgweb: add docFromHTML javascript function
>
> It takes a string with HTML markup and creates DOM document from it.
>
> diff -r 0258e9b301d3 -r 4b97b9c7034e mercurial/templates/static/mercurial.js
> --- a/mercurial/templates/static/mercurial.js	Sat Aug 17 15:59:45 2013 +0400
> +++ b/mercurial/templates/static/mercurial.js	Sat Aug 17 15:35:40 2013 +0400
> @@ -329,6 +329,12 @@
>       return xfr;
>   }
>   
> +function docFromHTML(html) {
> +    var doc = document.implementation.createHTMLDocument('');
> +    doc.documentElement.innerHTML = html;
> +    return doc;
> +}

https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation.createHTMLDocument

...says createHTMLDocument() is not supported in IE8.

Which Matt said earlier was important to support.

What about using document.createDocumentFragment() instead? Then you 
also don’t have the issue of needing to import the nodes afterwards, 
cause document fragments are owned by the original document.

~Laurens



More information about the Mercurial-devel mailing list