From 03eb54b37902db771accd3a53bad1b927c058bc7 Mon Sep 17 00:00:00 2001 From: David Petersen Date: Sat, 26 Mar 2011 16:49:14 -0400 Subject: [PATCH] Tabs: Deprecate the length method. Fixes #7143 Tabs: Deprecate the length method --- tests/unit/tabs/tabs_deprecated.js | 6 ++++++ tests/unit/tabs/tabs_methods.js | 7 ------- tests/unit/tabs/tabs_tickets.js | 4 ++-- ui/jquery.ui.tabs.js | 10 ++++++---- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index b385a33c2..880ea075e 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -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'); 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'); +}); + +test('length', function() { + expect(1); + el = $('#tabs1').tabs(); + equals(el.tabs('length'), $('ul a', el).length, ' should return length'); }); }( jQuery ) ); diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js index ac0747df9..44c91d492 100644 --- a/tests/unit/tabs/tabs_methods.js +++ b/tests/unit/tabs/tabs_methods.js @@ -167,11 +167,4 @@ test('url', function() { 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); diff --git a/tests/unit/tabs/tabs_tickets.js b/tests/unit/tabs/tabs_tickets.js index 5da799730..c301e9eb0 100644 --- a/tests/unit/tabs/tabs_tickets.js +++ b/tests/unit/tabs/tabs_tickets.js @@ -54,7 +54,7 @@ test('#4033 - IE expands hash to full url and misinterprets tab as ajax', functi el = $('
') .appendTo('#main').tabs(); - + 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); el = $('#tabs6').tabs(); - equals(el.tabs( "length" ), 2, 'should contain 2 tab'); + equals(el.data("tabs").anchors.length, 2, 'should contain 2 tab'); }); diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 03f085ea2..c026858ee 100755 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -568,10 +568,6 @@ $.widget( "ui.tabs", { url: function( index, url ) { this.anchors.eq( index ).data( "load.tabs", url ); return this; - }, - - length: function() { - return this.anchors.length; } }); @@ -812,6 +808,12 @@ if ( $.uiBackCompat !== false ) { }; }( jQuery, jQuery.ui.tabs.prototype ) ); + // length method + (function( $, prototype ) { + prototype.length = function() { + return this.anchors.length; + }; + }( jQuery, jQuery.ui.tabs.prototype ) ); } })( jQuery ); -- 2.39.5