]> source.dussan.org Git - jquery-ui.git/commitdiff
Tabs: fixed to work with empty nav list again.
authorScott González <scott.gonzalez@gmail.com>
Fri, 25 Dec 2009 18:25:46 +0000 (18:25 +0000)
committerScott González <scott.gonzalez@gmail.com>
Fri, 25 Dec 2009 18:25:46 +0000 (18:25 +0000)
Fixes #4997 - No longer possible to start with empty tab then add() elements dynamically.

tests/unit/tabs/tabs.html
tests/unit/tabs/tabs_core.js
ui/jquery.ui.tabs.js

index 0675fc308a3b09fd727011ea1fbf6b8fbcd5165d..b45f544d925b1ce45b297ee1695b78419a4132b2 100644 (file)
                        <div id="colon:test"></div>
                        <div style="height: 300px;" id="inline-style"></div>
                </div>
+               <div id="tabs3">
+                       <div>
+                               <ul id="tabs3-list">
+                                       <li><a href="#tabs3-1">1</a></li>
+                               </ul>
+                       </div>
+               </div>
+               <div id="tabs4">
+                       <ul id="tabs4-list">
+                               <li><a href="#tabs4-1">1</a></li>
+                       </ul>
+                       <ol>
+                               <li><a href="#tabs4-1">1</a></li>
+                       </ol>
+               </div>
+               <div id="tabs4a">
+                       <ol id="tabs4a-list">
+                               <li><a href="#tabs4a-1">1</a></li>
+                       </ol>
+                       <ul>
+                               <li><a href="#tabs4a-1">1</a></li>
+                       </ul>
+               </div>
+               <div id="tabs5">
+                       <div>
+                               <ul id="tabs5-list"></ul>
+                       </div>
+               </div>
        </div>
 </body>
 </html>
index 79e95ea4175dadb22a622bc6901c314405e0eac0..20ab2b1fde3bbd1d5889972d60dca91f5cd5bd96 100644 (file)
@@ -7,6 +7,24 @@ var el;
 
 module("tabs: core");
 
+test('navigation markup', function() {
+       el = $('#tabs3').tabs();
+       ok($('#tabs3-list').hasClass('ui-tabs-nav'), 'custom markup; allow list to be any descendant');
+       el.tabs('destroy');
+
+       el = $('#tabs4').tabs();
+       ok($('#tabs4-list').hasClass('ui-tabs-nav'), 'first list found becomes nav - ul');
+       el.tabs('destroy');
+
+       el = $('#tabs4a').tabs();
+       ok($('#tabs4a-list').hasClass('ui-tabs-nav'), 'first list found becomes nav - ol');
+       el.tabs('destroy');
+
+       el = $('#tabs5').tabs();
+       ok($('#tabs5-list').hasClass('ui-tabs-nav'), 'empty list can be used');
+       el.tabs('destroy');
+});
+
 test('ajax', function() {
        expect(4);
        stop();
@@ -34,6 +52,5 @@ test('ajax', function() {
        });
        
 });
-       
-       
+
 })(jQuery);
index 32f326d00101dfed4066d31a6e090965e0c48386..b9fad83d4b3e71b2c94245fd684f91f3b6d99d0e 100644 (file)
@@ -68,8 +68,7 @@ $.widget("ui.tabs", {
 
        _tabify: function(init) {
 
-               // use $('li:first').parent() so we can find the first ul/ol in DOM order
-               this.list = this.element.find('li:first').parent();
+               this.list = this.element.find('ol,ul').eq(0);
                this.lis = $('li:has(a[href])', this.list);
                this.anchors = this.lis.map(function() { return $('a', this)[0]; });
                this.panels = $([]);