[PATCH 10 of 20] hgweb: add appendHTML javascript function

Alexander Plavin alexander at plav.in
Fri Aug 9 13:57:35 CDT 2013


# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1376053040 -14400
#      Fri Aug 09 16:57:20 2013 +0400
# Node ID a6f9aff2141f3654ab8d04347d24f3ed236a542f
# Parent  14a87d839b2d7d9223150d2c8073d9df0062533b
hgweb: add appendHTML javascript function

If available, uses fast insertAdjacentHTML method. Otherwise falls back to
innerHTML concatenation.

diff -r 14a87d839b2d -r a6f9aff2141f mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js	Fri Aug 09 16:51:53 2013 +0400
+++ b/mercurial/templates/static/mercurial.js	Fri Aug 09 16:57:20 2013 +0400
@@ -351,3 +351,12 @@
         nodes[0].parentNode.removeChild(nodes[0]);
     }
 }
+
+function appendHTML(element, html) {
+    if (element.insertAdjacentHTML) {
+        element.insertAdjacentHTML('beforeend', html);
+    } else {
+        // compatibility fallback, can be much slower
+        element.innerHTML += html;
+    }
+}


More information about the Mercurial-devel mailing list