mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Tabs: Updated tests.
This commit is contained in:
parent
eaddfedd66
commit
7e03d4ea9d
@ -15,7 +15,8 @@
|
|||||||
<link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
|
<link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
|
||||||
<script type="text/javascript" src="../../../external/qunit.js"></script>
|
<script type="text/javascript" src="../../../external/qunit.js"></script>
|
||||||
<script type="text/javascript" src="../../jquery.simulate.js"></script>
|
<script type="text/javascript" src="../../jquery.simulate.js"></script>
|
||||||
|
<script type="text/javascript" src="../testsuite.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="tabs_core.js"></script>
|
<script type="text/javascript" src="tabs_core.js"></script>
|
||||||
<script type="text/javascript" src="tabs_defaults.js"></script>
|
<script type="text/javascript" src="tabs_defaults.js"></script>
|
||||||
<script type="text/javascript" src="tabs_events.js"></script>
|
<script type="text/javascript" src="tabs_events.js"></script>
|
||||||
|
@ -97,7 +97,7 @@ test('remove', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('select', function() {
|
test('select', function() {
|
||||||
expect(9);
|
expect(6);
|
||||||
|
|
||||||
el = $('#tabs1').tabs();
|
el = $('#tabs1').tabs();
|
||||||
|
|
||||||
@ -114,21 +114,12 @@ test('select', function() {
|
|||||||
el.tabs('select', -1);
|
el.tabs('select', -1);
|
||||||
equals(el.tabs('option', 'selected'), -1, 'should collapse tab passing in -1');
|
equals(el.tabs('option', 'selected'), -1, 'should collapse tab passing in -1');
|
||||||
|
|
||||||
el.tabs('destroy');
|
|
||||||
el.tabs({ collapsible: true });
|
|
||||||
el.tabs('select', null);
|
|
||||||
equals(el.tabs('option', 'selected'), -1, 'should collapse tab passing in null (deprecated)');
|
|
||||||
el.tabs('select', null);
|
|
||||||
equals(el.tabs('option', 'selected'), -1, 'should not select tab passing in null a second time (deprecated)');
|
|
||||||
|
|
||||||
el.tabs('destroy');
|
el.tabs('destroy');
|
||||||
el.tabs();
|
el.tabs();
|
||||||
el.tabs('select', 0);
|
el.tabs('select', 0);
|
||||||
equals(el.tabs('option', 'selected'), 0, 'should not collapse tab if collapsible is not set to true');
|
equals(el.tabs('option', 'selected'), 0, 'should not collapse tab if collapsible is not set to true');
|
||||||
el.tabs('select', -1);
|
el.tabs('select', -1);
|
||||||
equals(el.tabs('option', 'selected'), 0, 'should not collapse tab if collapsible is not set to true');
|
equals(el.tabs('option', 'selected'), 0, 'should not collapse tab if collapsible is not set to true');
|
||||||
el.tabs('select', null);
|
|
||||||
equals(el.tabs('option', 'selected'), 0, 'should not collapse tab if collapsible is not set to true');
|
|
||||||
|
|
||||||
el.tabs('select', '#fragment-2');
|
el.tabs('select', '#fragment-2');
|
||||||
equals(el.tabs('option', 'selected'), 1, 'should select tab by id');
|
equals(el.tabs('option', 'selected'), 1, 'should select tab by id');
|
||||||
|
10
ui/jquery.ui.tabs.js
vendored
10
ui/jquery.ui.tabs.js
vendored
@ -416,14 +416,10 @@ $.widget("ui.tabs", {
|
|||||||
_getIndex: function(index) {
|
_getIndex: function(index) {
|
||||||
// meta-function to give users option to provide a href string instead of a numerical index.
|
// meta-function to give users option to provide a href string instead of a numerical index.
|
||||||
// also sanitizes numerical indexes to valid values.
|
// also sanitizes numerical indexes to valid values.
|
||||||
if (typeof(index) == 'string') {
|
if (typeof index == 'string') {
|
||||||
index = this.anchors.index(this.anchors.filter('[href$=' + index + ']'));
|
index = this.anchors.index(this.anchors.filter('[href$=' + index + ']'));
|
||||||
index = (index ==-1?NaN:index);
|
|
||||||
}else if (typeof(index) != 'number') {
|
|
||||||
index = NaN;
|
|
||||||
}else if (index > this.anchors.length) {
|
|
||||||
index = this.anchors.length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -579,7 +575,7 @@ $.widget("ui.tabs", {
|
|||||||
|
|
||||||
select: function(index) {
|
select: function(index) {
|
||||||
index = this._getIndex(index);
|
index = this._getIndex(index);
|
||||||
if (isNaN(index) && this.options.collapsible) {
|
if (index == -1 && this.options.collapsible) {
|
||||||
index = this.options.selected;
|
index = this.options.selected;
|
||||||
}
|
}
|
||||||
this.anchors.eq(index).trigger(this.options.event + '.tabs');
|
this.anchors.eq(index).trigger(this.options.event + '.tabs');
|
||||||
|
Loading…
Reference in New Issue
Block a user