From 0dc7b16e94ebb6ad27bcf8f12d62efac7d610db5 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Tue, 2 Aug 2011 22:50:58 -0400 Subject: [PATCH] Fixes #8858. Pass the .trigger(..., data) to the event.special._default method. --- src/event.js | 2 +- test/unit/event.js | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/event.js b/src/event.js index cc85ec56a..bcf46f9a8 100644 --- a/src/event.js +++ b/src/event.js @@ -346,7 +346,7 @@ jQuery.event = { if ( !event.isDefaultPrevented() ) { special = jQuery.event.special[ type ] || {}; - if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) && + if ( (!special._default || special._default.call( elem.ownerDocument, event, data ) === false) && !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { // Call a native DOM method on the target with the same name name as the event. diff --git a/test/unit/event.js b/test/unit/event.js index 235ab4bcb..31bc6c92f 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -148,7 +148,7 @@ test("bind(), multiple events at once and namespaces", function() { }); test("bind(), namespace with special add", function() { - expect(24); + expect(27); var div = jQuery("
").bind("test", function(e) { ok( true, "Test event fired." ); @@ -157,10 +157,11 @@ test("bind(), namespace with special add", function() { var i = 0; jQuery.event.special.test = { - _default: function(e) { + _default: function(e, data) { equals( this, document, "Make sure we're at the top of the chain." ); equals( e.type, "test", "And that we're still dealing with a test event." ); equals( e.target, div[0], "And that the target is correct." ); + ok( data !== undefined , "And that trigger data was passed." ); }, setup: function(){}, teardown: function(){ @@ -189,13 +190,13 @@ test("bind(), namespace with special add", function() { }); // Should trigger 5 - div.trigger("test"); + div.trigger("test", 33.33); // Should trigger 2 - div.trigger("test.a"); + div.trigger("test.a", "George Harrison"); // Should trigger 2 - div.trigger("test.b"); + div.trigger("test.b", { year: 1982 }); // Should trigger 4 div.unbind("test"); -- 2.39.5