Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tabbed.children.forEach((tab, key) => {
const isActiveTab = tab === activeTab;
if (isActiveTab || (childrenNodes[key] && childrenNodes[key].properties.classes['visible'])) {
tab.invalidate();
const tabVNode = tab.render();
tabVNode.properties.classes['visible'] = isActiveTab;
childrenNodes[key] = tabVNode;
}
/* else, this tab isn't active and hasn't been previously rendered */
tabs.push(h(tabbed.tagNames.tab, {
key: tab,
classes: { active: isActiveTab },
'data-tab-id': `${tabbed.state.id || tabbedList.indexOf(tabbed)}-${tab.state.id || key}`
}, getTabChildVNode(tab)));
});
if (isActiveTab || (childrenNodes[key] && childrenNodes[key].properties.classes['visible'])) {
tab.invalidate();
const tabVNode = tab.render();
tabVNode.properties.classes['visible'] = isActiveTab;
childrenNodes[key] = tabVNode;
}
/* else, this tab isn't active and hasn't been previously rendered */
tabs.push(h(tabbed.tagNames.tab, {
key: tab,
classes: { active: isActiveTab },
'data-tab-id': `${tabbed.state.id || tabbedList.indexOf(tabbed)}-${tab.state.id || key}`
}, getTabChildVNode(tab)));
});
return [ h(tabbed.tagNames.tabBar, tabs), h('div.panels', childrenNodes) ];
}
}
render(): VNode {
const dijit: Dijit = this;
const afterCreate = dijitDataWeakMap.get(dijit).afterCreate;
return h(dijit.tagName, { afterCreate });
},
get dijit(): DijitWidget {
return [ h(list.tagNames.list, items.map((item) => h(list.tagNames.item, { key: item }, [ item.label ]))) ];
}
function getTabChildVNode(tab: TabbedChild): (VNode | string)[] {
const tabListeners = getTabListeners(tabbed, tab);
const nodes = [ h('div.tab-label', { onclick: tabListeners.onclickTabListener }, [ tab.state.label ]) ];
if (tab.state.closeable) {
nodes.push(h('div.tab-close', { onclick: tabListeners.onclickTabCloseListener }, [ 'X' ]));
}
return nodes;
}
function getTabChildVNode(tab: TabbedChild): (VNode | string)[] {
const tabListeners = getTabListeners(tabbed, tab);
const nodes = [ h('div.tab-label', { onclick: tabListeners.onclickTabListener }, [ tab.state.label ]) ];
if (tab.state.closeable) {
nodes.push(h('div.tab-close', { onclick: tabListeners.onclickTabCloseListener }, [ 'X' ]));
}
return nodes;
}