Skip to content
Permalink
Browse files

Fixes #8858. Pass the .trigger(..., data) to the event.special._defau…

…lt method.
  • Loading branch information...
dmethvin authored and timmywil committed Aug 3, 2011
1 parent d74c6bd commit 0dc7b16e94ebb6ad27bcf8f12d62efac7d610db5
Showing with 7 additions and 6 deletions.
  1. +1 −1 src/event.js
  2. +6 −5 test/unit/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.
@@ -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("<div/>").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");

0 comments on commit 0dc7b16

Please sign in to comment.
You can’t perform that action at this time.