Fixes #10477. Get .off(type, null, fn) right.

This commit is contained in:
Dave Methvin 2011-10-11 20:30:07 -04:00
parent d29182e8d0
commit 6afc2c074b
2 changed files with 14 additions and 3 deletions

View File

@ -953,7 +953,7 @@ jQuery.fn.extend({
}
return this;
}
if ( typeof selector !== "string" ) {
if ( selector === false || typeof selector === "function" ) {
// ( types [, fn] )
fn = selector;
selector = undefined;

View File

@ -704,7 +704,7 @@ test("bind()/trigger()/unbind() on plain object", function() {
});
test("unbind(type)", function() {
expect( 0 );
expect( 1 );
var $elem = jQuery("#firstp"),
message;
@ -736,6 +736,17 @@ test("unbind(type)", function() {
$elem.bind("error1 error2.test",error)
.unbind()
.trigger("error1").triggerHandler("error2");
// Should only unbind the specified function
jQuery( document ).bind( "click", function(){
ok( true, "called handler after selective removal");
});
var func = function(){ };
jQuery( document )
.bind( "click", func )
.unbind( "click", func )
.click()
.unbind( "click" );
});
test("unbind(eventObject)", function() {