Skip to content
Permalink
Browse files

Fix #10705. Don't bail too soon in `.off()` event string processing.

  • Loading branch information...
dmethvin committed Nov 10, 2011
1 parent 654930d commit dd363d2c0f8d5eb03fe7beccff44a4a35887caa0
Showing with 27 additions and 3 deletions.
  1. +3 −3 src/event.js
  2. +24 −0 test/unit/event.js
@@ -76,7 +76,7 @@ jQuery.event = {

// Handle multiple events separated by a space
// jQuery(...).bind("mouseover mouseout", fn);
types = hoverHack(types).split( " " );
types = jQuery.trim( hoverHack(types) ).split( " " );
for ( t = 0; t < types.length; t++ ) {

tns = rtypenamespace.exec( types[t] ) || [];
@@ -159,7 +159,7 @@ jQuery.event = {
}

// Once for each type.namespace in types; type may be omitted
types = hoverHack( types || "" ).split(" ");
types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
for ( t = 0; t < types.length; t++ ) {
tns = rtypenamespace.exec( types[t] ) || [];
type = tns[1];
@@ -171,7 +171,7 @@ jQuery.event = {
for ( j in events ) {
jQuery.event.remove( elem, j + namespaces, handler, selector );
}
return;
continue;
}

special = jQuery.event.special[ type ] || {};
@@ -2458,6 +2458,30 @@ test(".on and .off", function() {
jQuery("#onandoff").remove();
});


test(".on and .off, selective mixed removal (#10705)", function() {
expect(7);

var clockout = 0,
timingx = function( e ) {
ok( true, "triggered " + e.type );
};

jQuery( '<p>Strange Pursuit</p>' )
.on( "click", timingx )
.on( "click.duty", timingx )
.on( "click.now", timingx )
.on( "devo", timingx )
.on( "future", timingx )
.trigger( "click" ) // 3
.trigger( "devo" ) // 1
.off( ".duty devo " ) // trailing space
.trigger( "future" ) // 1
.trigger( "click" ) // 2
.off( "future click" )
.trigger( "click" ); // 0
});

test("delegated events quickIs", function() {
expect(14);
var markup = jQuery(

0 comments on commit dd363d2

Please sign in to comment.
You can’t perform that action at this time.