- this.tabContentsByName = {};
- this.tabButtonsByName = {};
- this.allContents = [];
- this.allButtons = [];
-
- for (const [key, elems] of Object.entries(this.$manyRefs || {})) {
- if (key.startsWith('toggle')) {
- const cleanKey = key.replace('toggle', '').toLowerCase();
- onSelect(elems, e => this.show(cleanKey));
- this.allButtons.push(...elems);
- this.tabButtonsByName[cleanKey] = elems;
- }
- if (key.startsWith('content')) {
- const cleanKey = key.replace('content', '').toLowerCase();
- this.tabContentsByName[cleanKey] = elems;
- this.allContents.push(...elems);
+ this.container = this.$el;
+ this.tabList = this.container.querySelector('[role="tablist"]');
+ this.tabs = Array.from(this.tabList.querySelectorAll('[role="tab"]'));
+ this.panels = Array.from(this.container.querySelectorAll(':scope > [role="tabpanel"], :scope > * > [role="tabpanel"]'));
+ this.activeUnder = this.$opts.activeUnder ? Number(this.$opts.activeUnder) : 10000;
+ this.active = null;
+
+ this.container.addEventListener('click', event => {
+ const tab = event.target.closest('[role="tab"]');
+ if (tab && this.tabs.includes(tab)) {
+ this.show(tab.getAttribute('aria-controls'));