From c2802d7aa05e6dc7731806a35d9f0057405a22c7 Mon Sep 17 00:00:00 2001 From: David Petersen Date: Wed, 17 Oct 2012 11:35:27 -0400 Subject: [PATCH] Accordion: handle active: null. Fixes #8694: 1.9 Accordion - active: null allows panels to be collapsible. --- tests/unit/accordion/accordion_options.js | 9 +++++++++ ui/jquery.ui.accordion.js | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index 5d950e1ac..8f0d0637f 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -13,6 +13,15 @@ test( "{ active: default }", function() { state( element, 1, 0, 0 ); }); +test( "{ active: null }", function() { + expect( 2 ); + var element = $( "#list1" ).accordion({ + active: null + }); + equal( element.accordion( "option", "active" ), 0 ); + state( element, 1, 0, 0 ); +}); + test( "{ active: false }", function() { expect( 7 ); var element = $( "#list1" ).accordion({ diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 48e880a05..ff07a8e93 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -59,8 +59,8 @@ $.widget( "ui.accordion", { .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" ) .hide(); - // don't allow collapsible: false and active: false - if ( !options.collapsible && options.active === false ) { + // don't allow collapsible: false and active: false / null + if ( !options.collapsible && ( !options.active || typeof options.active !== "number" ) ) { options.active = 0; } // handle negative values