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

This commit is contained in:
Dave Methvin 2011-11-09 21:29:15 -05:00
parent 654930de21
commit dd363d2c0f
2 changed files with 27 additions and 3 deletions

View File

@ -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 ] || {};

View File

@ -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(