Patchwork [10,of,20] hgweb: add appendHTML javascript function

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 9, 2013, 6:57 p.m.
Message ID <a6f9aff2141f3654ab8d.1376074655@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2116/
State Changes Requested
Headers show

Comments

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

Patch

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