Skip to content

Commit 771600f

Browse files
committed
Revert "Event: remove guard for falsy handler argument of jQuery#on method"
This reverts commit fac67a9.
1 parent 3870fbd commit 771600f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/event.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ function on( elem, types, selector, data, fn, one ) {
7474
}
7575
if ( fn === false ) {
7676
fn = returnFalse;
77+
} else if ( !fn ) {
78+
return elem;
7779
}
7880

7981
if ( one === 1 ) {

test/unit/event.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@ QUnit.module( "event", {
55
teardown: moduleTeardown
66
} );
77

8-
QUnit.test( "on() with non-null,defined data", function( assert ) {
8+
QUnit.test( "null or undefined handler", function( assert ) {
9+
assert.expect( 2 );
10+
11+
// Supports Fixes bug #7229
12+
try {
13+
jQuery( "#firstp" ).on( "click", null );
14+
ok( true, "Passing a null handler will not throw an exception" );
15+
} catch ( e ) {}
916

17+
try {
18+
jQuery( "#firstp" ).on( "click", undefined );
19+
ok( true, "Passing an undefined handler will not throw an exception" );
20+
} catch ( e ) {}
21+
} );
22+
23+
QUnit.test( "on() with non-null,defined data", function( assert ) {
1024
assert.expect( 2 );
1125

1226
var handler = function( event, data ) {

0 commit comments

Comments
 (0)