test(".on and .off", function() {
expect(9);
- var counter;
+ var counter, mixfn;
jQuery( '<div id="onandoff"><p>on<b>and</b>off</p><div>worked<em>or</em>borked?</div></div>' ).appendTo( 'body' );
// Direct events only
counter = 0;
- jQuery( "#onandoff em" )
+ jQuery( "#onandoff b" )
.on( "click", 5, function( e, trig ) {
counter += e.data + (trig || 9); // twice, 5+9+5+17=36
})
.each( function() {
equals( counter, 49, "after triggering em element" );
})
+ .off( "cluck", function(){} ) // shouldn't remove anything
.trigger( "cluck", 2 ) // 0+2 = 2
.each( function() {
equals( counter, 51, "after triggering #onandoff cluck" );
equals( counter, 51, "after triggering b" );
})
.trigger( "cluck", 3 ) // 0+3 = 3
- .off( "clack", "em" )
+ .off( "clack", "em", mixfn )
.find( "em" )
.trigger( "clack" ) // 0
.end()
// We should have removed all the event handlers ... kinda hacky way to check this
var data = jQuery.data[ jQuery( "#onandoff" )[0].expando ] || {};
- equals( data.events, null, "no events left" );
+ equals( data.events, undefined, "no events left" );
jQuery("#onandoff").remove();
});