Skip to content
Permalink
Browse files

Tabs: Account for non-tab list items on init. Fixes #8568 - jQuery ui…

… tabs: wrong default active li if ul contains extraneous elements.
  • Loading branch information
scottgonzalez committed Sep 12, 2012
1 parent 01e3af4 commit 7023ed4699b0c52e253ba2b3949d08b3dac2905b
Showing with 26 additions and 1 deletion.
  1. +8 −0 tests/unit/tabs/tabs.html
  2. +9 −0 tests/unit/tabs/tabs_core.js
  3. +8 −0 tests/unit/tabs/tabs_deprecated.html
  4. +1 −1 ui/jquery.ui.tabs.js
@@ -145,6 +145,14 @@ <h2 id="qunit-userAgent"></h2>
</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>
@@ -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(),
@@ -144,6 +144,14 @@ <h2 id="qunit-userAgent"></h2>
</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>
@@ -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;
}

0 comments on commit 7023ed4

Please sign in to comment.
You can’t perform that action at this time.