Skip to content
Permalink
Browse files

special.handle now must call the handleObj.handler if it wants that t…

…o happen. Also re-use the simulate() function for bubbling focusin.
  • Loading branch information...
dmethvin authored and timmywil committed Aug 14, 2011
1 parent 6a670df commit 990c094f1ceded54f93631d4ceb2c649a3b171be
Showing with 23 additions and 29 deletions.
  1. +23 −29 src/event.js
@@ -565,21 +565,19 @@ function dispatch( target, event, handlers, args ) {
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {

if ( !specialHandle || specialHandle.call( target, event, handleObj ) === false ) {
// Pass in a reference to the handler function itself
// So that we can later remove it
event.handler = handleObj.handler;
event.data = handleObj.data;
event.handleObj = handleObj;

ret = handleObj.handler.apply( target, args );

if ( ret !== undefined ) {
event.result = ret;
if ( ret === false ) {
event.preventDefault();
event.stopPropagation();
}
// Pass in a reference to the handler function itself
// So that we can later remove it
event.handler = handleObj.handler;
event.data = handleObj.data;
event.handleObj = handleObj;

ret = (specialHandle || handleObj.handler).apply( target, args );

if ( ret !== undefined ) {
event.result = ret;
if ( ret === false ) {
event.preventDefault();
event.stopPropagation();
}
}
}
@@ -702,20 +700,24 @@ jQuery.each({
delegateType: fix,
bindType: fix,

handle: function( event, handleObj ) {
handle: function( event ) {
var target = this,
related = event.relatedTarget,
selector = handleObj.selector;
handleObj = event.handleObj,
selector = handleObj.selector,
oldType, ret;

if ( selector && related ) {
// Delegated event; find the real relatedTarget
related = jQuery( related ).closest( selector )[0];
}
if ( !related || related !== target && !jQuery.contains( target, related ) ) {
//TODO: don't clobber event.type permanently
oldType = event.type;
event.type = handleObj.origType;
return false;
ret = handleObj.handler.apply( this, arguments );
event.type = oldType;
}
return ret;
}
};
});
@@ -907,16 +909,8 @@ if ( !jQuery.support.focusinBubbles ) {
}
};

function handler( donor ) {
// Donor event is always a native one; fix it and switch its type.
// Let focusin/out handler cancel the donor focus/blur event.
var e = jQuery.event.fix( donor );
e.type = fix;
e.originalEvent = {};
jQuery.event.trigger( e, null, e.target );
if ( e.isDefaultPrevented() ) {
donor.preventDefault();
}
function handler( event ) {
simulate( fix, jQuery.event.fix( event ), event.target, true );
}
});
}

0 comments on commit 990c094

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