Tabs: Account for non-tab list items on init. Fixes #8568 - jQuery ui tabs: wrong default active li if ul contains extraneous elements.

This commit is contained in:
Scott González 2012-09-12 09:28:51 -04:00
parent 01e3af4b92
commit 7023ed4699
4 changed files with 26 additions and 1 deletions

View File

@ -145,6 +145,14 @@
</div>
</div>
<div id="tabs9">
<ul>
<li>not a tab</li>
<li><a href="#tabs9-1">tab</a></li>
</ul>
<div id="tabs9-1"></div>
</div>
</div>
</body>
</html>

View File

@ -44,6 +44,15 @@ test( "disconnected from DOM", function() {
equal( element.find( ".ui-tabs-panel" ).length, 3, "should initialize panels" );
});
test( "non-tab list items", function() {
expect( 2 );
var element = $( "#tabs9" ).tabs();
equal( element.tabs( "option", "active" ), 0, "defaults to first tab" );
equal( element.find( ".ui-tabs-nav li.ui-state-active" ).index(), 1,
"first actual tab is active" );
});
test( "aria-controls", function() {
expect( 7 );
var element = $( "#tabs1" ).tabs(),

View File

@ -144,6 +144,14 @@
</div>
</div>
<div id="tabs9">
<ul>
<li>not a tab</li>
<li><a href="#tabs9-1">tab</a></li>
</ul>
<div id="tabs9-1"></div>
</div>
</div>
</body>
</html>

View File

@ -102,7 +102,7 @@ $.widget( "ui.tabs", {
// handle numbers: negative, out of range
if ( active !== false ) {
active = this.tabs.eq( active ).index();
active = this.tabs.index( this.tabs.eq( active ) );
if ( active === -1 ) {
active = options.collapsible ? false : 0;
}