mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
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:
parent
01e3af4b92
commit
7023ed4699
@ -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>
|
||||
|
@ -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 @@
|
||||
</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>
|
||||
|
2
ui/jquery.ui.tabs.js
vendored
2
ui/jquery.ui.tabs.js
vendored
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user