From 010102c2c24df1fb7826904933ab110f112852a2 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 10 Sep 2019 17:07:36 +0200 Subject: [PATCH] luci-base: cbi.js: find dropdown and browser instances early Gather dropdown and file browser widget nodes early, before initializing dynamic list widgets as dynlists invoke a dependency update which in turn might remove widget nodes from dom before they have been initialized. Ref: https://github.com/openwrt/luci/issues/2997#issuecomment-524251601 Signed-off-by: Jo-Philipp Wich --- modules/luci-base/htdocs/luci-static/resources/cbi.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index fa61cf644..0de7bcb9c 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -736,7 +736,9 @@ function cbi_d_update() { } function cbi_init() { - var nodes; + var dropdowns = document.querySelectorAll('.cbi-dropdown'), + browsers = document.querySelectorAll('[data-browser]'), + nodes; nodes = document.querySelectorAll('[data-strings]'); @@ -808,8 +810,8 @@ function cbi_init() { node.getAttribute('data-type')); } - document.querySelectorAll('.cbi-dropdown').forEach(cbi_dropdown_init); - document.querySelectorAll('[data-browser]').forEach(cbi_browser_init); + dropdowns.forEach(cbi_dropdown_init); + browsers.querySelectorAll('[data-browser]').forEach(cbi_browser_init); document.querySelectorAll('.cbi-tooltip:not(:empty)').forEach(function(s) { s.parentNode.classList.add('cbi-tooltip-container'); -- 2.25.1