mirror of
https://github.com/jquery/jquery.git
synced 2026-02-01 09:44:56 -05:00
Event: Fix chaining .on() with null handlers
Fixes gh-2846
This commit is contained in:
committed by
Timmy Willison
parent
780cac802b
commit
17f0e26ad9
@@ -5,6 +5,28 @@ QUnit.module( "event", {
|
||||
teardown: moduleTeardown
|
||||
} );
|
||||
|
||||
QUnit.test( "null or undefined handler", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
// Supports Fixes bug #7229
|
||||
try {
|
||||
jQuery( "#firstp" ).on( "click", null );
|
||||
assert.ok( true, "Passing a null handler will not throw an exception" );
|
||||
} catch ( e ) {}
|
||||
|
||||
try {
|
||||
jQuery( "#firstp" ).on( "click", undefined );
|
||||
assert.ok( true, "Passing an undefined handler will not throw an exception" );
|
||||
} catch ( e ) {}
|
||||
|
||||
var expectedElem = jQuery( "#firstp" );
|
||||
var actualElem = expectedElem.on( "click", null );
|
||||
assert.equal(actualElem, expectedElem, "Passing a null handler should return the original element");
|
||||
|
||||
actualElem = expectedElem.on( "click", undefined );
|
||||
assert.equal(actualElem, expectedElem, "Passing a null handler should return the original element");
|
||||
} );
|
||||
|
||||
QUnit.test( "on() with non-null,defined data", function( assert ) {
|
||||
|
||||
assert.expect( 2 );
|
||||
|
||||
Reference in New Issue
Block a user