From 80b6de1b7877f228f7fc5ce1a85766538f4218a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 4 Apr 2011 11:53:19 -0400 Subject: [PATCH] Accordion: Pass original event in beforeActivate event. --- tests/unit/accordion/accordion_events.js | 7 ++++++- ui/jquery.ui.accordion.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js index 0b9f14706..f7d9aabef 100644 --- a/tests/unit/accordion/accordion_events.js +++ b/tests/unit/accordion/accordion_events.js @@ -3,7 +3,7 @@ module( "accordion: events", accordionSetupTeardown() ); test( "beforeActivate", function() { - expect( 42 ); + expect( 47 ); var ac = $( "#list1" ).accordion({ active: false, collapsible: true @@ -12,6 +12,7 @@ test( "beforeActivate", function() { var content = ac.find( ".ui-accordion-content" ); ac.one( "accordionbeforeactivate", function( event, ui ) { + ok( !( "originalEvent" in event ) ); equals( ui.oldHeader.size(), 0 ); equals( ui.oldContent.size(), 0 ); equals( ui.newHeader.size(), 1 ); @@ -24,6 +25,7 @@ test( "beforeActivate", function() { state( ac, 1, 0, 0 ); ac.one( "accordionbeforeactivate", function( event, ui ) { + equals( event.originalEvent.type, "click" ); equals( ui.oldHeader.size(), 1 ); strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] ); equals( ui.oldContent.size(), 1 ); @@ -38,6 +40,7 @@ test( "beforeActivate", function() { state( ac, 0, 1, 0 ); ac.one( "accordionbeforeactivate", function( event, ui ) { + ok( !( "originalEvent" in event ) ); equals( ui.oldHeader.size(), 1 ); strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] ); equals( ui.oldContent.size(), 1 ); @@ -50,6 +53,7 @@ test( "beforeActivate", function() { state( ac, 0, 0, 0 ); ac.one( "accordionbeforeactivate", function( event, ui ) { + ok( !( "originalEvent" in event ) ); equals( ui.oldHeader.size(), 0 ); equals( ui.oldContent.size(), 0 ); equals( ui.newHeader.size(), 1 ); @@ -63,6 +67,7 @@ test( "beforeActivate", function() { state( ac, 0, 0, 0 ); ac.one( "accordionbeforeactivate", function( event, ui ) { + equals( event.originalEvent.type, "click" ); equals( ui.oldHeader.size(), 0 ); equals( ui.oldContent.size(), 0 ); equals( ui.newHeader.size(), 1 ); diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 95fa1d163..c658d4dbb 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -319,7 +319,7 @@ $.widget( "ui.accordion", { // click on active header, but not collapsible ( clickedIsActive && !options.collapsible ) || // allow canceling activation - ( this._trigger( "beforeActivate", null, eventData ) === false ) ) { + ( this._trigger( "beforeActivate", event, eventData ) === false ) ) { return; } -- 2.39.5