if ( special.add ) {
special.add.call( elem, handleObj );
+
+ if ( !handleObj.handler.guid ) {
+ handleObj.handler.guid = handler.guid;
+ }
}
// Add the function to the element's handler list
}
// remove generic event handler if no more handlers exist
- if ( jQuery.isEmptyObject( events[ type ] ) ) {
+ if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
removeEvent( elem, type, elemData.handle );
}
// Check if mouse(over|out) are still within the same parent element
var parent = event.relatedTarget;
- // Traverse up the tree
- while ( parent && parent !== this ) {
- // Firefox sometimes assigns relatedTarget a XUL element
- // which we cannot access the parentNode property of
- try {
+ // Firefox sometimes assigns relatedTarget a XUL element
+ // which we cannot access the parentNode property of
+ try {
+ // Traverse up the tree
+ while ( parent && parent !== this ) {
parent = parent.parentNode;
-
- // assuming we've left the element since we most likely mousedover a xul element
- } catch(e) {
- break;
}
- }
- if ( parent !== this ) {
- // set the correct event type
- event.type = event.data;
+ if ( parent !== this ) {
+ // set the correct event type
+ event.type = event.data;
- // handle event if we actually just moused on to a non sub-element
- jQuery.event.handle.apply( this, arguments );
- }
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+ // assuming we've left the element since we most likely mousedover a xul element
+ } catch(e) { }
},
// In case of event delegation, we only need to rename the event.type,
},
setup: function( data, namespaces ) {
+ if ( this.type === "file" ) {
+ return false;
+ }
+
for ( var type in changeFilters ) {
jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
}
}
});
+var liveMap = {
+ focus: "focusin",
+ blur: "focusout",
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+};
+
jQuery.each(["live", "die"], function( i, name ) {
jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
- var type, i = 0, match, namespaces,
+ var type, i = 0, match, namespaces, preType,
selector = origSelector || this.selector,
context = origSelector ? this : jQuery( this.context );
type = type.replace( rnamespaces, "" );
}
- type = type === "focus" ? "focusin" : // focus --> focusin
- type === "blur" ? "focusout" : // blur --> focusout
- type === "hover" ? types.push("mouseleave" + namespaces) && "mouseenter" : // hover support
- type;
+ if ( type === "hover" ) {
+ types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
+ continue;
+ }
+
+ preType = type;
+
+ if ( type === "focus" || type === "blur" ) {
+ types.push( liveMap[ type ] + namespaces );
+ type = type + namespaces;
- type += namespaces;
+ } else {
+ type = (liveMap[ type ] || type) + namespaces;
+ }
if ( name === "live" ) {
// bind live handler
context.each(function(){
jQuery.event.add( this, liveConvert( type, selector ),
- { data: data, selector: selector, handler: fn, origType: type, origHandler: fn } );
+ { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
});
} else {
events = jQuery.data( this, "events" );
// Make sure we avoid non-left-click bubbling in Firefox (#3861)
- if ( event.liveFired === this || !events || event.button && event.type === "click" ) {
+ if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) {
return;
}
related = null;
// Those two events require additional checking
- if ( handleObj.origType === "mouseenter" || handleObj.origType === "mouseleave" ) {
+ if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
}