Fix live mouseenter and mouseleave binding so they can be activated by triggers. Fixes #6514.

This commit is contained in:
Brian Brennan 2011-04-17 11:58:20 -07:00 committed by John Resig
parent 21c0be8496
commit d46042e050
2 changed files with 20 additions and 3 deletions

View file

@ -1066,7 +1066,7 @@ jQuery.each(["live", "die"], function( i, name ) {
preType = type; preType = type;
if ( type === "focus" || type === "blur" ) { if ( type === "focus" || type === "blur" || type === "mouseenter" || type === "mouseleave" ) {
types.push( liveMap[ type ] + namespaces ); types.push( liveMap[ type ] + namespaces );
type = type + namespaces; type = type + namespaces;

View file

@ -832,7 +832,7 @@ test("trigger() bubbling", function() {
}); });
test("trigger(type, [data], [fn])", function() { test("trigger(type, [data], [fn])", function() {
expect(14); expect(16);
var handler = function(event, a, b, c) { var handler = function(event, a, b, c) {
equals( event.type, "click", "check passed data" ); equals( event.type, "click", "check passed data" );
@ -849,7 +849,24 @@ test("trigger(type, [data], [fn])", function() {
ok( true, "Native call was triggered" ); ok( true, "Native call was triggered" );
}; };
// Triggers handlrs and native
$elem.live('mouseenter', function(){
ok( true, 'Trigger mouseenter bound by live' );
});
$elem.live('mouseleave', function(){
ok( true, 'Trigger mouseleave bound by live' );
});
$elem.trigger('mouseenter');
$elem.trigger('mouseleave');
$elem.die('mouseenter');
$elem.die('mouseleave');
// Triggers handlrs and native
// Trigger 5 // Trigger 5
$elem.bind("click", handler).trigger("click", [1, "2", "abc"]); $elem.bind("click", handler).trigger("click", [1, "2", "abc"]);