Commit 67d43604 authored by Aarni Koskela's avatar Aarni Koskela

get_tab_index(): use a for loop with early-exit for performance

parent 563e88dd
...@@ -100,15 +100,13 @@ function switch_to_extras() { ...@@ -100,15 +100,13 @@ function switch_to_extras() {
} }
function get_tab_index(tabId) { function get_tab_index(tabId) {
var res = 0; let buttons = gradioApp().getElementById(tabId).querySelector('div').querySelectorAll('button');
for (let i = 0; i < buttons.length; i++) {
gradioApp().getElementById(tabId).querySelector('div').querySelectorAll('button').forEach(function(button, i) { if (buttons[i].classList.contains('selected')) {
if (button.className.indexOf('selected') != -1) { return i;
res = i;
} }
}); }
return 0;
return res;
} }
function create_tab_index_args(tabId, args) { function create_tab_index_args(tabId, args) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment