fix: fix various issues raised by code review

This commit is contained in:
alistair3149 2024-11-16 02:52:19 -05:00 committed by alistair3149
parent 40fe7d2e52
commit 9e8ac878cc
3 changed files with 5 additions and 5 deletions

View file

@ -126,7 +126,7 @@ class TabberTransclude {
*/
private static function getTabHTML( array $tabData ): string {
$tabpanelId = "tabber-tabpanel-{$tabData['id']}";
return Html::rawElement( 'a', [
return Html::element( 'a', [
'class' => 'tabber__tab',
'id' => "tabber-tab-{$tabData['id']}",
'href' => "#$tabpanelId",

View file

@ -58,17 +58,18 @@ class Transclude {
credentials: 'same-origin',
signal: controller.signal
} );
clearTimeout( timeoutId );
if ( !response.ok ) {
throw new Error( `[TabberNeue] Network response was not ok: ${ response.status } - ${ response.statusText }` );
}
return Promise.resolve( response.text() );
return response.text();
} catch ( error ) {
if ( error.name === 'AbortError' ) {
return Promise.reject( new Error( '[TabberNeue] Request timed out after 5000ms' ) );
} else {
return Promise.reject( new Error( `[TabberNeue] Error fetching data from URL: ${ this.url } - ${ error }` ) );
}
} finally {
clearTimeout( timeoutId );
}
}

View file

@ -406,7 +406,7 @@ class TabberBuilder {
setTabsAttributes() {
const tabAttributes = {
tabindex: '-1',
'aria-selected': false
'aria-selected': 'false'
};
for ( const tab of this.tablist.children ) {
Util.setAttributes( tab, tabAttributes );
@ -457,7 +457,6 @@ class TabberBuilder {
tabberEvent.init();
this.tabber.classList.remove( 'tabber--init' );
this.tabber.classList.add( 'tabber--live' );
TabberAction.setActiveTab( activeTab );
}
}