Patchwork [3,of,5] hgweb: add docFromHTML javascript function

login
register
mail settings
Submitter Alexander Plavin
Date Sept. 18, 2013, 6:33 p.m.
Message ID <5877a02a4fe62cf43e5e.1379529197@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2522/
State Accepted
Commit 2a9a21e1e1dbfd92c391f4a617556d0da5786bd5
Headers show

Comments

Alexander Plavin - Sept. 18, 2013, 6:33 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@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

Patch

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;
+}