Skip to content
Permalink
Browse files

fix for #4234. hover can take one function to use for both enter and …

…leave.
  • Loading branch information
brandonaaron committed May 6, 2009
1 parent 3a9c827 commit 8f042d8be34fe2d197e45d6fa398456759a4c007
Showing with 19 additions and 1 deletion.
  1. +1 −1 src/event.js
  2. +18 −0 test/unit/event.js
@@ -569,7 +569,7 @@ jQuery.fn.extend({
},

hover: function( fnOver, fnOut ) {
return this.mouseenter( fnOver ).mouseleave( fnOut );
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
},

ready: function( fn ) {
@@ -233,6 +233,24 @@ test("unbind(eventObject)", function() {
assert( 0 );
});

test("hover()", function() {
var times = 0,
handler1 = function( event ) { ++times; },
handler2 = function( event ) { ++times; };

jQuery("#firstp")
.hover(handler1, handler2)
.mouseenter().mouseleave()
.unbind("mouseenter", handler1)
.unbind("mouseleave", handler2)
.hover(handler1)
.mouseenter().mouseleave()
.unbind("mouseenter mouseleave", handler1)
.mouseenter().mouseleave();

equals( times, 4, "hover handlers fired" );
});

test("trigger() shortcuts", function() {
expect(6);
jQuery('<li><a href="#">Change location</a></li>').prependTo('#firstUL').find('a').bind('click', function() {

0 comments on commit 8f042d8

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