Commit 8f042d8b authored by Brandon Aaron's avatar Brandon Aaron

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

parent 3a9c827b
...@@ -569,7 +569,7 @@ jQuery.fn.extend({ ...@@ -569,7 +569,7 @@ jQuery.fn.extend({
}, },
hover: function( fnOver, fnOut ) { hover: function( fnOver, fnOut ) {
return this.mouseenter( fnOver ).mouseleave( fnOut ); return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
}, },
ready: function( fn ) { ready: function( fn ) {
......
...@@ -233,6 +233,24 @@ test("unbind(eventObject)", function() { ...@@ -233,6 +233,24 @@ test("unbind(eventObject)", function() {
assert( 0 ); 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() { test("trigger() shortcuts", function() {
expect(6); expect(6);
jQuery('<li><a href="#">Change location</a></li>').prependTo('#firstUL').find('a').bind('click', function() { jQuery('<li><a href="#">Change location</a></li>').prependTo('#firstUL').find('a').bind('click', function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment