[PATCH 3 of 5] hgweb: add docFromHTML javascript function

Alexander Plavin alexander at plav.in
Wed Sep 18 13:33:17 CDT 2013


# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1378459857 -14400
#      Fri Sep 06 13:30:57 2013 +0400
# Node ID 5877a02a4fe62cf43e5e7972ea29bfcb7b7497f9
# Parent  9ae2d8d0823a34439d94335b42aea155531850f4
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

diff -r 9ae2d8d0823a -r 5877a02a4fe6 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;
+}


More information about the Mercurial-devel mailing list