From d67bc412a869938cb85ff02e10a78befd7409a1a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 24 Oct 2012 11:11:47 -0400 Subject: [PATCH] Accordion: Removed deprecated activate method and expanded active option. Fixes #6837 - Accordion: Remove the activate method. Fixes #6853 - Accordion: Remove support for non-number/falsey values for active option. --- tests/unit/accordion/accordion_deprecated.js | 101 ------------------- tests/unit/accordion/accordion_options.js | 40 ++++---- ui/jquery.ui.accordion.js | 19 ---- 3 files changed, 19 insertions(+), 141 deletions(-) diff --git a/tests/unit/accordion/accordion_deprecated.js b/tests/unit/accordion/accordion_deprecated.js index d410e07e2..879a26e7b 100644 --- a/tests/unit/accordion/accordion_deprecated.js +++ b/tests/unit/accordion/accordion_deprecated.js @@ -4,107 +4,6 @@ var equalHeight = TestHelpers.accordion.equalHeight, setupTeardown = TestHelpers.accordion.setupTeardown, state = TestHelpers.accordion.state; -module( "accordion (deprecated): expanded active option, activate method", setupTeardown() ); - -test( "activate, numeric", function() { - expect( 5 ); - var element = $( "#list1" ).accordion({ active: 1 }); - state( element, 0, 1, 0 ); - element.accordion( "activate", 2 ); - state( element, 0, 0, 1 ); - element.accordion( "activate", 0 ); - state( element, 1, 0, 0 ); - element.accordion( "activate", 1 ); - state( element, 0, 1, 0 ); - element.accordion( "activate", 2 ); - state( element, 0, 0, 1 ); -}); - -test( "activate, numeric, collapsible:true", function() { - expect( 3 ); - var element = $( "#list1" ).accordion({ collapsible: true }); - element.accordion( "activate", 2 ); - state( element, 0, 0, 1 ); - element.accordion( "activate", 0 ); - state( element, 1, 0, 0 ); - element.accordion( "activate", -1 ); - state( element, 0, 0, 0 ); -}); - -test( "activate, boolean, collapsible: true", function() { - expect( 2 ); - var element = $( "#list1" ).accordion({ collapsible: true }); - element.accordion( "activate", 2 ); - state( element, 0, 0, 1 ); - element.accordion( "activate", false ); - state( element, 0, 0, 0 ); -}); - -test( "activate, boolean, collapsible: false", function() { - expect( 2 ); - var element = $( "#list1" ).accordion(); - element.accordion( "activate", 2 ); - state( element, 0, 0, 1 ); - element.accordion( "activate", false ); - state( element, 0, 0, 1 ); -}); - -test( "activate, string expression", function() { - expect( 4 ); - var element = $( "#list1" ).accordion({ active: "h3:last" }); - state( element, 0, 0, 1 ); - element.accordion( "activate", ":first" ); - state( element, 1, 0, 0 ); - element.accordion( "activate", ":eq(1)" ); - state( element, 0, 1, 0 ); - element.accordion( "activate", ":last" ); - state( element, 0, 0, 1 ); -}); - -test( "activate, jQuery or DOM element", function() { - expect( 3 ); - var element = $( "#list1" ).accordion({ active: $( "#list1 h3:last" ) }); - state( element, 0, 0, 1 ); - element.accordion( "activate", $( "#list1 h3:first" ) ); - state( element, 1, 0, 0 ); - element.accordion( "activate", $( "#list1 h3" )[ 1 ] ); - state( element, 0, 1, 0 ); -}); - -test( "{ active: Selector }", function() { - expect( 2 ); - var element = $("#list1").accordion({ - active: "h3:last" - }); - state( element, 0, 0, 1 ); - element.accordion( "option", "active", "h3:eq(1)" ); - state( element, 0, 1, 0 ); -}); - -test( "{ active: Element }", function() { - expect( 2 ); - var element = $( "#list1" ).accordion({ - active: $( "#list1 h3:last" )[ 0 ] - }); - state( element, 0, 0, 1 ); - element.accordion( "option", "active", $( "#list1 h3:eq(1)" )[ 0 ] ); - state( element, 0, 1, 0 ); -}); - -test( "{ active: jQuery Object }", function() { - expect( 2 ); - var element = $( "#list1" ).accordion({ - active: $( "#list1 h3:last" ) - }); - state( element, 0, 0, 1 ); - element.accordion( "option", "active", $( "#list1 h3:eq(1)" ) ); - state( element, 0, 1, 0 ); -}); - - - - - module( "accordion (deprecated) - resize", setupTeardown() ); test( "resize", function() { diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index 8f0d0637f..214753e40 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -65,28 +65,26 @@ test( "{ active: Number }", function() { state( element, 0, 1, 0 ); }); -if ( $.uiBackCompat === false ) { - test( "{ active: -Number }", function() { - expect( 8 ); - var element = $( "#list1" ).accordion({ - active: -1 - }); - equal( element.accordion( "option", "active" ), 2 ); - state( element, 0, 0, 1 ); - - element.accordion( "option", "active", -2 ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); - - element.accordion( "option", "active", -10 ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); - - element.accordion( "option", "active", -3 ); - equal( element.accordion( "option", "active" ), 0 ); - state( element, 1, 0, 0 ); +test( "{ active: -Number }", function() { + expect( 8 ); + var element = $( "#list1" ).accordion({ + active: -1 }); -} + equal( element.accordion( "option", "active" ), 2 ); + state( element, 0, 0, 1 ); + + element.accordion( "option", "active", -2 ); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); + + element.accordion( "option", "active", -10 ); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); + + element.accordion( "option", "active", -3 ); + equal( element.accordion( "option", "active" ), 0 ); + state( element, 1, 0, 0 ); +}); test( "{ animate: false }", function() { expect( 3 ); diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 76076131d..53e9189fc 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -544,25 +544,6 @@ $.widget( "ui.accordion", { // DEPRECATED if ( $.uiBackCompat !== false ) { - // expanded active option, activate method - (function( $, prototype ) { - prototype.activate = prototype._activate; - - var _findActive = prototype._findActive; - prototype._findActive = function( index ) { - if ( index === -1 ) { - index = false; - } - if ( index && typeof index !== "number" ) { - index = this.headers.index( this.headers.filter( index ) ); - if ( index === -1 ) { - index = false; - } - } - return _findActive.call( this, index ); - }; - }( jQuery, jQuery.ui.accordion.prototype ) ); - // resize method jQuery.ui.accordion.prototype.resize = jQuery.ui.accordion.prototype.refresh; -- 2.39.5