Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 6afc2c074bec5c19063c8f8ebca6bfb53c7d4cef 1 parent d29182e
@dmethvin dmethvin authored
Showing with 14 additions and 3 deletions.
  1. +1 −1  src/event.js
  2. +13 −2 test/unit/event.js
View
2  src/event.js
@@ -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
15 test/unit/event.js
@@ -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(){ };

isn't it good idea to add ok(false, "should not be called"); inside the body of func ?

@dmethvin Owner

It certainly wouldn't hurt, although that is not the point of the particular test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ 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)" );
Please sign in to comment.
Something went wrong with that request. Please try again.