]> source.dussan.org Git - jquery.git/commitdiff
fix for #4234. hover can take one function to use for both enter and leave.
authorBrandon Aaron <brandon.aaron@gmail.com>
Wed, 6 May 2009 02:17:24 +0000 (02:17 +0000)
committerBrandon Aaron <brandon.aaron@gmail.com>
Wed, 6 May 2009 02:17:24 +0000 (02:17 +0000)
src/event.js
test/unit/event.js

index 8d737bf4bb3e84b7e1c81c00dc4a8089da0928ec..ebf1231cba0b43f95d04a7beb4f6bf947a6ea774 100644 (file)
@@ -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 ) {
index 63c640d1195a61a17c0f7647b20171c8c52c74f3..98833ece87d9267fb025ae840a92be19467b7972 100644 (file)
@@ -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() {