]> source.dussan.org Git - jquery-ui.git/commitdiff
Tabs: Account for non-tab list items on init. Fixes #8568 - jQuery ui tabs: wrong...
authorScott González <scott.gonzalez@gmail.com>
Wed, 12 Sep 2012 13:28:51 +0000 (09:28 -0400)
committerScott González <scott.gonzalez@gmail.com>
Wed, 12 Sep 2012 13:28:51 +0000 (09:28 -0400)
tests/unit/tabs/tabs.html
tests/unit/tabs/tabs_core.js
tests/unit/tabs/tabs_deprecated.html
ui/jquery.ui.tabs.js

index 3a55f3b79186846bebf8cd0c60d34b18c0c3fdd6..e6c95472763a463e8156dd9c1ba24a6107605e2e 100644 (file)
        </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>
index 53dd50a98c78d60c51259b5a69a6731a504e1432..5dbe1d6b123bc0d0446c0835a25927235cedb7b8 100644 (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(),
index bb40883508b68db20b271984b87f736581ee66a2..9d3ecef3a9c1607a2c36af613f8dbcd143aa0ad9 100644 (file)
        </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>
index 7631366d61283a7f76e486ba32252baef94215ea..60377ad13d721400444d46c4fabf965c97c67949 100644 (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;
                        }