summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorOlli Asikainen <olli.asikainen@gmail.com>2021-06-30 02:03:00 +0300
committerJo-Philipp Wich <jo@mein.io>2021-07-13 19:55:26 +0200
commitf919635310286b3b905aedb716d707da1ea2c811 (patch)
treec2654445aa619407eda57ad488494a87c450c669 /modules
parentb6ca2947e93ddd5d5c4a43b51e75d79f4ce06049 (diff)
luci-base: batch DOM updates to prevent slowdown
Signed-off-by: Olli Asikainen <olli.asikainen@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/cbi.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index 22cbecc864..2fc2f09632 100644
--- a/modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js
@@ -752,7 +752,7 @@ function cbi_update_table(table, data, placeholder) {
});
if (Array.isArray(data)) {
- var n = 0, rows = target.querySelectorAll('tr, .tr');
+ var n = 0, rows = target.querySelectorAll('tr, .tr'), trows = [];
data.forEach(function(row) {
var trow = E('tr', { 'class': 'tr' });
@@ -770,12 +770,16 @@ function cbi_update_table(table, data, placeholder) {
trow.classList.add('cbi-rowstyle-%d'.format((n++ % 2) ? 2 : 1));
- if (rows[n])
- target.replaceChild(trow, rows[n]);
- else
- target.appendChild(trow);
+ trows[n] = trow;
});
+ for (var i = 1; i < n; i++) {
+ if (rows[i])
+ target.replaceChild(trows[i], rows[i]);
+ else
+ target.appendChild(trows[i]);
+ }
+
while (rows[++n])
target.removeChild(rows[n]);