mirror of
https://github.com/jquery/jquery.git
synced 2024-12-09 08:04:24 +00:00
Event: Fix chaining .on() with null handlers
Fixes gh-2812 Close gh-2825
This commit is contained in:
parent
df31b88135
commit
c4d9eac930
@ -71,7 +71,7 @@ function on( elem, types, selector, data, fn, one ) {
|
|||||||
if ( fn === false ) {
|
if ( fn === false ) {
|
||||||
fn = returnFalse;
|
fn = returnFalse;
|
||||||
} else if ( !fn ) {
|
} else if ( !fn ) {
|
||||||
return this;
|
return elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( one === 1 ) {
|
if ( one === 1 ) {
|
||||||
|
@ -6,7 +6,7 @@ QUnit.module( "event", {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "null or undefined handler", function( assert ) {
|
QUnit.test( "null or undefined handler", function( assert ) {
|
||||||
assert.expect( 2 );
|
assert.expect( 4 );
|
||||||
|
|
||||||
// Supports Fixes bug #7229
|
// Supports Fixes bug #7229
|
||||||
try {
|
try {
|
||||||
@ -18,6 +18,13 @@ QUnit.test( "null or undefined handler", function( assert ) {
|
|||||||
jQuery( "#firstp" ).on( "click", undefined );
|
jQuery( "#firstp" ).on( "click", undefined );
|
||||||
assert.ok( true, "Passing an undefined handler will not throw an exception" );
|
assert.ok( true, "Passing an undefined handler will not throw an exception" );
|
||||||
} catch ( e ) {}
|
} 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 ) {
|
QUnit.test( "on() with non-null,defined data", function( assert ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user