mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Tabs: fixed bug related to setting selected via data method, cleaned up mess in tests
This commit is contained in:
parent
78adee126c
commit
fbc6ff5f81
@ -99,39 +99,34 @@ test('panelTemplate', function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
|
||||
test('selected: null', function() { // TODO move to selected
|
||||
expect(2);
|
||||
test('selected', function() {
|
||||
expect(8);
|
||||
|
||||
el = $('#tabs1');
|
||||
el = $('#tabs1').tabs();
|
||||
equals(el.data('selected.tabs'), 0, 'should be 0 by default');
|
||||
|
||||
el.tabs({ selected: null });
|
||||
el.tabs('destroy');
|
||||
el.tabs({ selected: -1 });
|
||||
equals(el.data('selected.tabs'), -1, 'should be -1 for all tabs unselected');
|
||||
equals( $('li.ui-tabs-selected', el).length, 0, 'no tab should be selected' );
|
||||
equals( $('div.ui-tabs-hide', '#tabs1').length, 3, 'all panels should be hidden' );
|
||||
|
||||
});
|
||||
el.tabs('destroy');
|
||||
el.tabs({ selected: null });
|
||||
equals(el.data('selected.tabs'), -1, 'should be -1 for all tabs unselected with value null (deprecated)');
|
||||
|
||||
test('selected', function() {
|
||||
expect(5);
|
||||
el.tabs('destroy');
|
||||
el.tabs({ selected: 1 });
|
||||
equals(el.data('selected.tabs'), 1, 'should be specified tab');
|
||||
|
||||
$('#tabs1').tabs();
|
||||
equals($('#tabs1').data('selected.tabs'), 0, 'selected should be 0 by default');
|
||||
|
||||
reset();
|
||||
$('#tabs1').tabs({ selected: null });
|
||||
equals($('#tabs1').data('selected.tabs'), -1, 'selected should be -1 for all tabs unselected');
|
||||
|
||||
reset();
|
||||
$('#tabs1').tabs({ selected: -1 });
|
||||
equals($('#tabs1').data('selected.tabs'), -1, 'selected should be -1 for all tabs unselected');
|
||||
|
||||
reset();
|
||||
$('#tabs1').tabs({ selected: 1 });
|
||||
equals($('#tabs1').data('selected.tabs'), 1, 'selected should be specified tab');
|
||||
|
||||
reset();
|
||||
$('#tabs1').tabs({ selected: 8 });
|
||||
equals($('#tabs1').data('selected.tabs'), 0, 'selected should default to zero if given value is out of index');
|
||||
el.tabs('destroy');
|
||||
el.tabs({ selected: 99 });
|
||||
equals(el.data('selected.tabs'), 0, 'selected should default to zero if given value is out of index');
|
||||
|
||||
el.tabs('destroy');
|
||||
el.tabs({ collapsible: true });
|
||||
el.data('selected.tabs', 0);
|
||||
equals(el.data('selected.tabs'), 0, 'should not collapse tab if value is same as selected');
|
||||
});
|
||||
|
||||
test('spinner', function() {
|
||||
|
@ -21,9 +21,12 @@ $.widget("ui.tabs", {
|
||||
},
|
||||
|
||||
_setData: function(key, value) {
|
||||
if (key == 'selected')
|
||||
this.select(value);
|
||||
if (key == 'selected') {
|
||||
if (this.options.collapsible
|
||||
&& value == this.options.selected) return;
|
||||
|
||||
this.select(value);
|
||||
}
|
||||
else {
|
||||
this.options[key] = value;
|
||||
if (key == 'deselectable')
|
||||
|
Loading…
Reference in New Issue
Block a user