(!m[2] || elem.id === m[2]) &&
(!m[3] || m[3].test( elem.className ))
);
+ },
+ hoverHack = function( events ) {
+ return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
};
/*
// Handle multiple events separated by a space
// jQuery(...).bind("mouseover mouseout", fn);
- types = types.replace( rhoverHack, "mouseover$1 mouseout$1" ).split( " " );
+ types = hoverHack(types).split( " " );
for ( t = 0; t < types.length; t++ ) {
tns = rtypenamespace.exec( types[t] ) || [];
}
// Once for each type.namespace in types; type may be omitted
- types = ( types || "" ).replace( rhoverHack, "mouseover$1 mouseout$1" ).split(" ");
+ types = hoverHack( types || "" ).split(" ");
for ( t = 0; t < types.length; t++ ) {
tns = rtypenamespace.exec( types[t] ) || [];
type = tns[1];
assert( 0 );
});
-test("hover()", function() {
+test("hover() and hover pseudo-event", function() {
+ expect(2);
+
var times = 0,
handler1 = function( event ) { ++times; },
handler2 = function( event ) { ++times; };
.mouseenter().mouseleave();
equals( times, 4, "hover handlers fired" );
+
+ var balance = 0;
+ jQuery( "#firstp" )
+ .bind("hover", function( e ) {
+ if ( e.type === "mouseenter" ) {
+ balance++;
+ } else if ( e.type === "mouseleave" ) {
+ balance--;
+ } else {
+ ok( false, "hover pseudo: unknown event type "+e.type );
+ }
+ })
+ .trigger("mouseenter")
+ .trigger("mouseleave")
+ .unbind("hover")
+ .trigger("mouseenter");
+
+ equals( balance, 0, "hover pseudo-event" );
});
test("mouseover triggers mouseenter", function() {