luci-base: ui.js: prevent race condition in tab initialization
Fixes: #3150 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
982ba6cf2f
commit
2b7ca79118
1 changed files with 7 additions and 0 deletions
|
@ -2021,6 +2021,9 @@ return L.Class.extend({
|
||||||
document.querySelectorAll('[data-tab]').forEach(function(tab) {
|
document.querySelectorAll('[data-tab]').forEach(function(tab) {
|
||||||
var parent = tab.parentNode;
|
var parent = tab.parentNode;
|
||||||
|
|
||||||
|
if (L.dom.matches(tab, 'li') && L.dom.matches(parent, 'ul.cbi-tabmenu'))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!parent.hasAttribute('data-tab-group'))
|
if (!parent.hasAttribute('data-tab-group'))
|
||||||
parent.setAttribute('data-tab-group', groups.length);
|
parent.setAttribute('data-tab-group', groups.length);
|
||||||
|
|
||||||
|
@ -2053,6 +2056,9 @@ return L.Class.extend({
|
||||||
groupId = +group.getAttribute('data-tab-group'),
|
groupId = +group.getAttribute('data-tab-group'),
|
||||||
selected = null;
|
selected = null;
|
||||||
|
|
||||||
|
if (group.getAttribute('data-initialized') === 'true')
|
||||||
|
return;
|
||||||
|
|
||||||
for (var i = 0, pane; pane = panes[i]; i++) {
|
for (var i = 0, pane; pane = panes[i]; i++) {
|
||||||
var name = pane.getAttribute('data-tab'),
|
var name = pane.getAttribute('data-tab'),
|
||||||
title = pane.getAttribute('data-tab-title'),
|
title = pane.getAttribute('data-tab-title'),
|
||||||
|
@ -2072,6 +2078,7 @@ return L.Class.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
group.parentNode.insertBefore(menu, group);
|
group.parentNode.insertBefore(menu, group);
|
||||||
|
group.setAttribute('data-initialized', true);
|
||||||
|
|
||||||
if (selected === null) {
|
if (selected === null) {
|
||||||
selected = this.getActiveTabId(panes[0]);
|
selected = this.getActiveTabId(panes[0]);
|
||||||
|
|
Loading…
Reference in a new issue