aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Waldron <waldron.rick@gmail.com>2012-01-12 20:30:45 -0500
committerDave Methvin <dave.methvin@gmail.com>2012-01-12 20:30:45 -0500
commitc0da49ff37484764bd0f33fe40d1a5f83d0f39e8 (patch)
tree6dd056ff6acd73e0921d48d59feca4fe440b92b0
parentd8289964788b6d5a31c2f89746c78079fb8a9869 (diff)
downloadjquery-c0da49ff37484764bd0f33fe40d1a5f83d0f39e8.tar.gz
jquery-c0da49ff37484764bd0f33fe40d1a5f83d0f39e8.zip
Fix #11130: Don't neglect the data arg when event-map is passed.
-rw-r--r--src/event.js4
-rw-r--r--test/unit/event.js22
2 files changed, 21 insertions, 5 deletions
diff --git a/src/event.js b/src/event.js
index 150aba2fd..c675937a3 100644
--- a/src/event.js
+++ b/src/event.js
@@ -867,9 +867,9 @@ jQuery.fn.extend({
// Types can be a map of types/handlers
if ( typeof types === "object" ) {
// ( types-Object, selector, data )
- if ( typeof selector !== "string" ) {
+ if ( typeof selector !== "string" ) { // && selector != null
// ( types-Object, data )
- data = selector;
+ data = data || selector;
selector = undefined;
}
for ( type in types ) {
diff --git a/test/unit/event.js b/test/unit/event.js
index 762617733..0932ce816 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -1197,7 +1197,7 @@ test("Delegated events in SVG (#10791)", function() {
'<rect id="svg-by-id" x="10" y="20" width="100" height="60" r="10" rx="10" ry="10"></rect>'+
'</svg>'
).appendTo( "body" );
-
+
jQuery( "body" )
.on( "click", "#svg-by-id", function() {
ok( true, "delegated id selector" );
@@ -2601,7 +2601,7 @@ test("special bind/delegate name mapping", function() {
// Ensure .one() events are removed after their maiden voyage
jQuery( '<p>Gut Feeling</p>' )
.one( "gutfeeling", jQuery.noop )
- .trigger( "gutfeeling" ) // This one should
+ .trigger( "gutfeeling" ) // This one should
.trigger( "gutfeeling" ) // This one should not
.remove();
@@ -2616,7 +2616,7 @@ test(".on and .off, selective mixed removal (#10705)", function() {
ok( true, "triggered " + e.type );
};
- jQuery( '<p>Strange Pursuit</p>' )
+ jQuery( "<p>Strange Pursuit</p>" )
.on( "click", timingx )
.on( "click.duty", timingx )
.on( "click.now", timingx )
@@ -2631,6 +2631,22 @@ test(".on and .off, selective mixed removal (#10705)", function() {
.trigger( "click" ); // 0
});
+test(".on( event-map, null-selector, data ) #11130", function() {
+
+ expect( 1 );
+
+ var $p = jQuery("<p>Strange Pursuit</p>"),
+ data = "bar",
+ map = {
+ "foo": function( event ) {
+ equal( event.data, "bar", "event.data correctly relayed with null selector" );
+ $p.remove();
+ }
+ };
+
+ $p.on( map, null, data ).trigger("foo");
+});
+
test("delegated events quickIs", function() {
expect(14);
var markup = jQuery(