]> source.dussan.org Git - jquery.git/commitdiff
Fixes #10477. Get `.off(type, null, fn)` right.
authorDave Methvin <dave.methvin@gmail.com>
Wed, 12 Oct 2011 00:30:07 +0000 (20:30 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Wed, 12 Oct 2011 00:31:45 +0000 (20:31 -0400)
src/event.js
test/unit/event.js

index 875f014d7cdf3dc1b0d0f331e0be31010be2c4a8..17872f02dfbbbf1965fea10c2fd2e0b7c2c83786 100644 (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;
index 9bf9f788c201278d5cebabd1a56ceb0ad91b825d..83f83469abb2b1ed3230785d5f346df4383ed8fe 100644 (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() {
@@ -1111,7 +1122,7 @@ test("jQuery.Event( type, props )", function() {
 
        // Supports jQuery.Event implementation
        equal( event.type, "keydown", "Verify type" );
-       
+
        // ensure "type" in props won't clobber the one set by constructor
        equal( jQuery.inArray("type", jQuery.event.props), -1, "'type' property not in props (#10375)" );