Implemented support for .context limited .closest() calls. Fixes #4072.
This commit is contained in:
parent
343b0936a4
commit
cae93c39eb
2 changed files with 11 additions and 4 deletions
|
@ -53,11 +53,12 @@ jQuery.fn.extend({
|
|||
|
||||
closest: function( selector ) {
|
||||
var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null,
|
||||
closer = 0;
|
||||
closer = 0,
|
||||
context = this.context;
|
||||
|
||||
return this.map(function(){
|
||||
var cur = this;
|
||||
while ( cur && cur.ownerDocument ) {
|
||||
while ( cur && cur.ownerDocument && cur !== context ) {
|
||||
if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) {
|
||||
jQuery.data(cur, "closest", closer);
|
||||
return cur;
|
||||
|
@ -120,4 +121,4 @@ jQuery.each({
|
|||
|
||||
return this.pushStack( jQuery.unique( ret ), name, selector );
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue