hgweb: add docFromHTML javascript function
authorAlexander Plavin <alexander@plav.in>
Fri, 06 Sep 2013 13:30:57 +0400
changeset 19741 2a9a21e1e1db
parent 19740 2228bd109706
child 19742 ac68009c31a4
hgweb: add docFromHTML javascript function It takes a string with HTML markup and creates DOM document from it. The implementation is a part of code from https://developer.mozilla.org/en-US/docs/Web/API/DOMParser#DOMParser_HTML_extension_for_other_browsers
mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js	Fri Sep 06 13:30:57 2013 +0400
+++ b/mercurial/templates/static/mercurial.js	Fri Sep 06 13:30:57 2013 +0400
@@ -328,3 +328,9 @@
     onstart();
     return xfr;
 }
+
+function docFromHTML(html) {
+    var doc = document.implementation.createHTMLDocument('');
+    doc.documentElement.innerHTML = html;
+    return doc;
+}