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.
This commit is contained in:
parent
0ae78024c2
commit
9aa0c69c43
5 changed files with 43 additions and 7 deletions
|
@ -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++;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue