Commit 0dc7b16e authored by Dave Methvin's avatar Dave Methvin Committed by timmywil

Fixes #8858. Pass the .trigger(..., data) to the event.special._default method.

parent d74c6bd0
...@@ -346,7 +346,7 @@ jQuery.event = { ...@@ -346,7 +346,7 @@ jQuery.event = {
if ( !event.isDefaultPrevented() ) { if ( !event.isDefaultPrevented() ) {
special = jQuery.event.special[ type ] || {}; 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 ) ) { !(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. // Call a native DOM method on the target with the same name name as the event.
......
...@@ -148,7 +148,7 @@ test("bind(), multiple events at once and namespaces", function() { ...@@ -148,7 +148,7 @@ test("bind(), multiple events at once and namespaces", function() {
}); });
test("bind(), namespace with special add", function() { test("bind(), namespace with special add", function() {
expect(24); expect(27);
var div = jQuery("<div/>").bind("test", function(e) { var div = jQuery("<div/>").bind("test", function(e) {
ok( true, "Test event fired." ); ok( true, "Test event fired." );
...@@ -157,10 +157,11 @@ test("bind(), namespace with special add", function() { ...@@ -157,10 +157,11 @@ test("bind(), namespace with special add", function() {
var i = 0; var i = 0;
jQuery.event.special.test = { 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( 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.type, "test", "And that we're still dealing with a test event." );
equals( e.target, div[0], "And that the target is correct." ); equals( e.target, div[0], "And that the target is correct." );
ok( data !== undefined , "And that trigger data was passed." );
}, },
setup: function(){}, setup: function(){},
teardown: function(){ teardown: function(){
...@@ -189,13 +190,13 @@ test("bind(), namespace with special add", function() { ...@@ -189,13 +190,13 @@ test("bind(), namespace with special add", function() {
}); });
// Should trigger 5 // Should trigger 5
div.trigger("test"); div.trigger("test", 33.33);
// Should trigger 2 // Should trigger 2
div.trigger("test.a"); div.trigger("test.a", "George Harrison");
// Should trigger 2 // Should trigger 2
div.trigger("test.b"); div.trigger("test.b", { year: 1982 });
// Should trigger 4 // Should trigger 4
div.unbind("test"); div.unbind("test");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment