aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-02-09 23:29:57 +0000
committerJohn Resig <jeresig@gmail.com>2009-02-09 23:29:57 +0000
commit9aa0c69c43bad9fce5ef7732692308afb2a38ec6 (patch)
tree8f4f5be81a2ba17d828e2fa4e1c1256a4ac10d14 /src
parent0ae78024c23dd3ef4bcea883338d975dcf843597 (diff)
downloadjquery-9aa0c69c43bad9fce5ef7732692308afb2a38ec6.tar.gz
jquery-9aa0c69c43bad9fce5ef7732692308afb2a38ec6.zip
Fixed bubbling of live events (if an inner element handles an event first - and stops progatation - then the parent event doesn't encounter the event). Thanks to Irae for the patch. Fixes bug #3980.
Diffstat (limited to 'src')
-rw-r--r--src/core.js8
-rw-r--r--src/event.js6
2 files changed, 11 insertions, 3 deletions
diff --git a/src/core.js b/src/core.js
index 3a9eaa7de..ac8ec6bc4 100644
--- a/src/core.js
+++ b/src/core.js
@@ -346,14 +346,18 @@ jQuery.fn = jQuery.prototype = {
},
closest: function( selector ) {
- var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null;
+ var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null,
+ closer = 0;
return this.map(function(){
var cur = this;
while ( cur && cur.ownerDocument ) {
- if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) )
+ if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) {
+ jQuery.data(cur, "closest", closer);
return cur;
+ }
cur = cur.parentNode;
+ closer++;
}
});
},
diff --git a/src/event.js b/src/event.js
index a621eb93e..e707015c1 100644
--- a/src/event.js
+++ b/src/event.js
@@ -571,9 +571,13 @@ function liveHandler( event ){
}
});
+ elems.sort(function(a,b) {
+ return jQuery.data(a.elem, "closest") - jQuery.data(b.elem, "closest");
+ });
+
jQuery.each(elems, function(){
if ( this.fn.call(this.elem, event, this.fn.data) === false )
- stop = false;
+ return (stop = false);
});
return stop;