aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2009-12-03 10:51:04 -0500
committerjeresig <jeresig@gmail.com>2009-12-03 10:51:04 -0500
commit4daae7a79f43815935a2890d16904c5a052717f3 (patch)
tree43e098868af8bbeb9900bb56b8889fd8ee4e533b
parente534a310c7e99c44d93855ad5865ad5e985039ba (diff)
downloadjquery-4daae7a79f43815935a2890d16904c5a052717f3.tar.gz
jquery-4daae7a79f43815935a2890d16904c5a052717f3.zip
No need to do the closest match if no selectors are passed in.
-rw-r--r--src/event.js49
-rw-r--r--src/traversing.js2
2 files changed, 34 insertions, 17 deletions
diff --git a/src/event.js b/src/event.js
index 2bb8a0edc..24e5ef11d 100644
--- a/src/event.js
+++ b/src/event.js
@@ -749,13 +749,30 @@ jQuery.fn.extend({
});
function liveHandler( event ) {
- var stop = true, elems = [], args = arguments;
+ var stop = true, elems = [], selectors = [], args = arguments,
+ related, match, fn, elem, j, i,
+ live = jQuery.extend({}, jQuery.data( this, "events" ).live);
- jQuery.each( jQuery.data( this, "events" ).live || [], function( i, fn ) {
- if ( fn.live === event.type ) {
- var elem = jQuery( event.target ).closest( fn.selector, event.currentTarget )[0],
- related;
- if ( elem ) {
+ for ( j in live ) {
+ if ( live[j].live === event.type ) {
+ selectors.push( live[j].selector );
+ }
+ }
+
+ console.log( event.type, selectors+"" );
+
+ // TODO: Make sure that duplicate selectors aren't run
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ console.log( "match", match, selectors+"" );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ for ( j in live ) {
+ fn = live[j];
+ elem = match[i].elem;
+ related = null;
+
+ if ( match[i].selector === fn.selector) {
// Those two events require additional checking
if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
@@ -766,19 +783,19 @@ function liveHandler( event ) {
}
}
}
- });
+ }
- elems.sort(function( a, b ) {
- return a.closer - b.closer;
- });
+ console.log( "elems", elems );
- jQuery.each(elems, function() {
- event.currentTarget = this.elem;
- event.data = this.fn.data;
- if ( this.fn.apply( this.elem, args ) === false ) {
- return (stop = false);
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+ event.currentTarget = match.elem;
+ event.data = match.fn.data;
+ if ( match.fn.apply( match.elem, args ) === false ) {
+ stop = false;
+ break;
}
- });
+ }
return stop;
}
diff --git a/src/traversing.js b/src/traversing.js
index 737efa429..796ae2f40 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -58,7 +58,7 @@ jQuery.fn.extend({
if ( jQuery.isArray( selectors ) ) {
var ret = [], cur = this[0], selector;
- if ( cur ) {
+ if ( cur && selectors.length ) {
for ( var i = 0, l = selectors.length; i < l; i++ ) {
selectors[i] = jQuery.expr.match.POS.test( selector ) ?
jQuery( selector, context || this.context ) :