Skip to content

Commit 03eb54b

Browse files
committed
Tabs: Deprecate the length method. Fixes #7143 Tabs: Deprecate the length method
1 parent e378876 commit 03eb54b

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

tests/unit/tabs/tabs_deprecated.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ test('#5069 - ui.tabs.add creates two tab panels when using a full URL', functio
139139
equals(el.children('div').length, el.find('> ul > li').length, 'After creation, number of panels should be equal to number of tabs');
140140
el.tabs('add', '/ajax_html_echo', 'Test');
141141
equals(el.children('div').length, el.find('> ul > li').length, 'After add, number of panels should be equal to number of tabs');
142+
});
143+
144+
test('length', function() {
145+
expect(1);
142146

147+
el = $('#tabs1').tabs();
148+
equals(el.tabs('length'), $('ul a', el).length, ' should return length');
143149
});
144150

145151
}( jQuery ) );

tests/unit/tabs/tabs_methods.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,4 @@ test('url', function() {
167167
ok(false, "missing test - untested code is broken code.");
168168
});
169169

170-
test('length', function() {
171-
expect(1);
172-
173-
el = $('#tabs1').tabs();
174-
equals(el.tabs('length'), $('ul a', el).length, ' should return length');
175-
});
176-
177170
})(jQuery);

tests/unit/tabs/tabs_tickets.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test('#4033 - IE expands hash to full url and misinterprets tab as ajax', functi
5454

5555
el = $('<div><ul><li><a href="#tab">Tab</a></li></ul><div id="tab"></div></div>')
5656
.appendTo('#main').tabs();
57-
57+
5858
equals($('a', el).data('load.tabs'), undefined, 'should not create ajax tab');
5959

6060
});
@@ -64,7 +64,7 @@ test('#5893 - Sublist in the tab list are considered as tab', function() {
6464
expect(1);
6565

6666
el = $('#tabs6').tabs();
67-
equals(el.tabs( "length" ), 2, 'should contain 2 tab');
67+
equals(el.data("tabs").anchors.length, 2, 'should contain 2 tab');
6868

6969
});
7070

ui/jquery.ui.tabs.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,6 @@ $.widget( "ui.tabs", {
568568
url: function( index, url ) {
569569
this.anchors.eq( index ).data( "load.tabs", url );
570570
return this;
571-
},
572-
573-
length: function() {
574-
return this.anchors.length;
575571
}
576572
});
577573

@@ -812,6 +808,12 @@ if ( $.uiBackCompat !== false ) {
812808
};
813809
}( jQuery, jQuery.ui.tabs.prototype ) );
814810

811+
// length method
812+
(function( $, prototype ) {
813+
prototype.length = function() {
814+
return this.anchors.length;
815+
};
816+
}( jQuery, jQuery.ui.tabs.prototype ) );
815817
}
816818

817819
})( jQuery );

0 commit comments

Comments
 (0)