Make liveHandler to use jQuery.lastCloser and speed up internal sorting.

This commit is contained in:
rkatic 2009-11-08 00:10:58 +08:00 committed by John Resig
parent 0f03c7489f
commit 3dc5bc5a8b

View file

@ -743,15 +743,15 @@ function liveHandler( event ) {
jQuery.each( jQuery.data( this, "events" ).live || [], function( i, fn ) {
if ( fn.live === event.type ) {
var elem = jQuery( event.target ).closest( fn.selector )[0];
var elem = jQuery( event.target ).closest( fn.selector, event.currentTarget )[0];
if ( elem ) {
elems.push({ elem: elem, fn: fn });
elems.push({ elem: elem, fn: fn, closer: jQuery.lastCloser });
}
}
});
elems.sort(function( a, b ) {
return jQuery.data( a.elem, "closest" ) - jQuery.data( b.elem, "closest" );
return a.closer - b.closer;
});
jQuery.each(elems, function() {