refactor: drop spread syntax for iterating nodeList

This commit is contained in:
alistair3149 2024-05-25 15:40:10 -04:00
parent 9162321c3c
commit 78a987d7c1
No known key found for this signature in database

View file

@ -415,15 +415,19 @@ class TabberEvent {
const tabpanels = tabberEl.querySelectorAll( ':scope > .tabber__section > .tabber__panel' ); const tabpanels = tabberEl.querySelectorAll( ':scope > .tabber__section > .tabber__panel' );
const tabs = tabberEl.querySelectorAll( ':scope > .tabber__header > .tabber__tabs > .tabber__tab' ); const tabs = tabberEl.querySelectorAll( ':scope > .tabber__header > .tabber__tabs > .tabber__tab' );
[ ...tabpanels ].forEach( ( tabpanel ) => { tabpanels.forEach( ( tabpanel ) => {
tabpanel.setAttribute( 'aria-hidden', 'true' ); tabpanel.setAttribute( 'aria-hidden', 'true' );
if ( typeof resizeObserver !== 'undefined' && resizeObserver ) { if ( typeof resizeObserver !== 'undefined' && resizeObserver ) {
resizeObserver.unobserve( tabpanel ); resizeObserver.unobserve( tabpanel );
} }
} ); } );
[ ...tabs ].forEach( ( tab ) => { tabs.forEach( ( tab ) => {
tab.setAttribute( 'aria-selected', 'false' ); const tabAttributes = {
'aria-selected': false,
tabindex: '-1'
};
Util.setAttributes( tab, tabAttributes );
} ); } );
// Ensure `resizeObserver` is defined before using it // Ensure `resizeObserver` is defined before using it
@ -432,6 +436,7 @@ class TabberEvent {
} }
activeTabpanel.setAttribute( 'aria-hidden', 'false' ); activeTabpanel.setAttribute( 'aria-hidden', 'false' );
activeTab.setAttribute( 'aria-selected', 'true' ); activeTab.setAttribute( 'aria-selected', 'true' );
activeTab.setAttribute( 'tabindex', '0' );
TabberEvent.updateIndicator( tabberEl, activeTab ); TabberEvent.updateIndicator( tabberEl, activeTab );
TabberEvent.setActiveTabpanel( activeTabpanel ); TabberEvent.setActiveTabpanel( activeTabpanel );
@ -648,7 +653,7 @@ class TabberBuilder {
createTabs() { createTabs() {
const fragment = document.createDocumentFragment(); const fragment = document.createDocumentFragment();
const tabpanels = this.tabber.querySelectorAll( ':scope > .tabber__section > .tabber__panel' ); const tabpanels = this.tabber.querySelectorAll( ':scope > .tabber__section > .tabber__panel' );
[ ...tabpanels ].forEach( ( tabpanel ) => { tabpanels.forEach( ( tabpanel ) => {
fragment.append( this.createTabElement( tabpanel ) ); fragment.append( this.createTabElement( tabpanel ) );
} ); } );