]> source.dussan.org Git - jquery.git/commitdiff
Revert "Event: remove guard for falsy handler argument of jQuery#on method"
authorTimmy Willison <timmywillisn@gmail.com>
Thu, 7 Jan 2016 18:59:47 +0000 (13:59 -0500)
committerTimmy Willison <timmywillisn@gmail.com>
Thu, 7 Jan 2016 18:59:47 +0000 (13:59 -0500)
This reverts commit fac67a984268ef8f7de952666fda6d8d32754f5f.

src/event.js
test/unit/event.js

index 8f6fd9f0c36dc57c2a114677084d0a9ef5e3a663..ae3ac3c96ab774a8401407df222305026477282c 100644 (file)
@@ -74,6 +74,8 @@ function on( elem, types, selector, data, fn, one ) {
        }
        if ( fn === false ) {
                fn = returnFalse;
+       } else if ( !fn ) {
+               return elem;
        }
 
        if ( one === 1 ) {
index 525a72d13938a4e78968f3a32898c23aeb68dbb8..a5d2412a9bc9cf2164f83a7bdc29c3f5408fa984 100644 (file)
@@ -5,8 +5,22 @@ QUnit.module( "event", {
        teardown: moduleTeardown
 } );
 
-QUnit.test( "on() with non-null,defined data", function( assert ) {
+QUnit.test( "null or undefined handler", function( assert ) {
+       assert.expect( 2 );
+
+       // Supports Fixes bug #7229
+       try {
+               jQuery( "#firstp" ).on( "click", null );
+               ok( true, "Passing a null handler will not throw an exception" );
+       } catch ( e ) {}
 
+       try {
+               jQuery( "#firstp" ).on( "click", undefined );
+               ok( true, "Passing an undefined handler will not throw an exception" );
+       } catch ( e ) {}
+} );
+
+QUnit.test( "on() with non-null,defined data", function( assert ) {
        assert.expect( 2 );
 
        var handler = function( event, data ) {