diff --git a/ui/tabs.js b/ui/tabs.js index 4ecfacaf34e..bb7b5f2f04c 100644 --- a/ui/tabs.js +++ b/ui/tabs.js @@ -352,16 +352,19 @@ return $.widget( "ui.tabs", { this._setupEvents( this.options.event ); this._setupHeightStyle( this.options.heightStyle ); - this.tabs.not( this.active ).attr( { - "aria-selected": "false", - "aria-expanded": "false", - tabIndex: -1 - } ); - this.panels.not( this._getPanelForTab( this.active ) ) - .hide() - .attr( { - "aria-hidden": "true" - } ); + this.tabs + .not( this.active ) + .attr( { + "aria-selected": "false", + "aria-expanded": "false", + tabIndex: -1 + } ); + this.panels + .not( this._getPanelForTab( this.active ) ) + .hide() + .attr( { + "aria-hidden": "true" + } ); // Make sure one tab is in the tab order if ( !this.active.length ) { @@ -412,16 +415,18 @@ return $.widget( "ui.tabs", { } } ); - this.tabs = this.tablist.find( "> li:has(a[href])" ) - .attr( { - role: "tab", - tabIndex: -1 - } ); + this.tabs = this.tablist + .find( "> li:has(a[href])" ) + .attr( { + role: "tab", + tabIndex: -1 + } ); this._addClass( this.tabs, "ui-tab", "ui-state-default" ); - this.anchors = this.tabs.map( function() { - return $( "a", this )[ 0 ]; - } ) + this.anchors = this.tabs + .map( function() { + return $( "a", this )[ 0 ]; + } ) .attr( { role: "presentation", tabIndex: -1 @@ -664,24 +669,27 @@ return $.widget( "ui.tabs", { "aria-selected": "false", "aria-expanded": "false" } ); + // If we're switching tabs, remove the old tab from the tab order. // If we're opening from collapsed state, remove the previous tab from the tab order. // If we're collapsing, then keep the collapsing tab in the tab order. if ( toShow.length && toHide.length ) { eventData.oldTab.attr( "tabIndex", -1 ); } else if ( toShow.length ) { - this.tabs.filter( function() { - return $( this ).attr( "tabIndex" ) === 0; - } ) - .attr( "tabIndex", -1 ); + this.tabs + .filter( function() { + return $( this ).attr( "tabIndex" ) === 0; + } ) + .attr( "tabIndex", -1 ); } toShow.attr( "aria-hidden", "false" ); - eventData.newTab.attr( { - "aria-selected": "true", - "aria-expanded": "true", - tabIndex: 0 - } ); + eventData.newTab + .attr( { + "aria-selected": "true", + "aria-expanded": "true", + tabIndex: 0 + } ); }, _activate: function( index ) {