Tabs: Deprecate the length method. Fixes #7143 Tabs: Deprecate the length method

This commit is contained in:
David Petersen 2011-03-26 16:49:14 -04:00
parent e378876918
commit 03eb54b379
4 changed files with 14 additions and 13 deletions

View File

@ -139,7 +139,13 @@ test('#5069 - ui.tabs.add creates two tab panels when using a full URL', functio
equals(el.children('div').length, el.find('> ul > li').length, 'After creation, number of panels should be equal to number of tabs'); equals(el.children('div').length, el.find('> ul > li').length, 'After creation, number of panels should be equal to number of tabs');
el.tabs('add', '/ajax_html_echo', 'Test'); el.tabs('add', '/ajax_html_echo', 'Test');
equals(el.children('div').length, el.find('> ul > li').length, 'After add, number of panels should be equal to number of tabs'); equals(el.children('div').length, el.find('> ul > li').length, 'After add, number of panels should be equal to number of tabs');
});
test('length', function() {
expect(1);
el = $('#tabs1').tabs();
equals(el.tabs('length'), $('ul a', el).length, ' should return length');
}); });
}( jQuery ) ); }( jQuery ) );

View File

@ -167,11 +167,4 @@ test('url', function() {
ok(false, "missing test - untested code is broken code."); ok(false, "missing test - untested code is broken code.");
}); });
test('length', function() {
expect(1);
el = $('#tabs1').tabs();
equals(el.tabs('length'), $('ul a', el).length, ' should return length');
});
})(jQuery); })(jQuery);

View File

@ -54,7 +54,7 @@ test('#4033 - IE expands hash to full url and misinterprets tab as ajax', functi
el = $('<div><ul><li><a href="#tab">Tab</a></li></ul><div id="tab"></div></div>') el = $('<div><ul><li><a href="#tab">Tab</a></li></ul><div id="tab"></div></div>')
.appendTo('#main').tabs(); .appendTo('#main').tabs();
equals($('a', el).data('load.tabs'), undefined, 'should not create ajax tab'); equals($('a', el).data('load.tabs'), undefined, 'should not create ajax tab');
}); });
@ -64,7 +64,7 @@ test('#5893 - Sublist in the tab list are considered as tab', function() {
expect(1); expect(1);
el = $('#tabs6').tabs(); el = $('#tabs6').tabs();
equals(el.tabs( "length" ), 2, 'should contain 2 tab'); equals(el.data("tabs").anchors.length, 2, 'should contain 2 tab');
}); });

10
ui/jquery.ui.tabs.js vendored
View File

@ -568,10 +568,6 @@ $.widget( "ui.tabs", {
url: function( index, url ) { url: function( index, url ) {
this.anchors.eq( index ).data( "load.tabs", url ); this.anchors.eq( index ).data( "load.tabs", url );
return this; return this;
},
length: function() {
return this.anchors.length;
} }
}); });
@ -812,6 +808,12 @@ if ( $.uiBackCompat !== false ) {
}; };
}( jQuery, jQuery.ui.tabs.prototype ) ); }( jQuery, jQuery.ui.tabs.prototype ) );
// length method
(function( $, prototype ) {
prototype.length = function() {
return this.anchors.length;
};
}( jQuery, jQuery.ui.tabs.prototype ) );
} }
})( jQuery ); })( jQuery );