]> source.dussan.org Git - jquery-ui.git/commitdiff
accordion: fixed incosistent accordionchange event arguments (http://dev.jquery.com...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Sun, 13 Jul 2008 14:42:27 +0000 (14:42 +0000)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Sun, 13 Jul 2008 14:42:27 +0000 (14:42 +0000)
tests/accordion.js
ui/ui.accordion.js

index e957acd431be7fec2a96a01ae9b74beb237a128b..ff3719b41a27bc188042df8b8d7ff89af9483d67 100644 (file)
@@ -99,4 +99,34 @@ test("handle click on header-descendant", function() {
        state2(ac, 0, 1, 0);
 });
 
+test("active:false", function() {
+       $("#list1").accordion({
+               active: false,
+               alwaysOpen: false
+       });
+       equals( $("#list1 a.selected").size(), 0, "no headers selected" );
+});
+
+test("accordionchange event, open closed and close again", function() {
+       expect(8);
+       $("#list1").accordion({
+               active: false,
+               alwaysOpen: false
+       })
+       .one("accordionchange", function(event, ui) {
+               equals( ui.oldHeader.size(), 0 )
+               equals( ui.oldContent.size(), 0 )
+               equals( ui.newHeader.size(), 1 )
+               equals( ui.newContent.size(), 1 )
+       })
+       .accordion("activate", 0)
+       .one("accordionchange", function(event, ui) {
+               equals( ui.oldHeader.size(), 1 )
+               equals( ui.oldContent.size(), 1 )
+               equals( ui.newHeader.size(), 0 )
+               equals( ui.newContent.size(), 0 )
+       })
+       .accordion("activate", 0);
+});
+
 })(jQuery);
index 2cf014b8ec7eb4d7f25f19daa63c8e13127fa57e..4865c317e0edb1ba75a2409b300663e5fcd25aab 100644 (file)
@@ -201,12 +201,11 @@ function clickHandler(event) {
        // find elements to show and hide
        var toShow = clicked.next(),
                toHide = options.active.next(),
-               //data = [clicked, options.active, toShow, toHide],
                data = {
                        options: options,
-                       newHeader: clicked,
+                       newHeader: clickedActive && !options.alwaysOpen ? $([]) : clicked,
                        oldHeader: options.active,
-                       newContent: toShow,
+                       newContent: clickedActive && !options.alwaysOpen ? $([]) : toShow,
                        oldContent: toHide
                },
                down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] );
@@ -218,7 +217,7 @@ function clickHandler(event) {
 };
 
 function findActive(headers, selector) {
-       return selector != undefined
+       return selector
                ? typeof selector == "number"
                        ? headers.filter(":eq(" + selector + ")")
                        : headers.not(headers.not(selector))