diff options
author | John Resig <jeresig@gmail.com> | 2009-07-25 21:31:59 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-07-25 21:31:59 +0000 |
commit | cae93c39eb57ccc2acc5e101eda7a56e0a734cdf (patch) | |
tree | 06fe36a01ff668f449a541aadeffb4dfd690ea5c /src/traversing.js | |
parent | 343b0936a43953a993d1f2cc500b954d5bcc8280 (diff) | |
download | jquery-cae93c39eb57ccc2acc5e101eda7a56e0a734cdf.tar.gz jquery-cae93c39eb57ccc2acc5e101eda7a56e0a734cdf.zip |
Implemented support for .context limited .closest() calls. Fixes #4072.
Diffstat (limited to 'src/traversing.js')
-rw-r--r-- | src/traversing.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/traversing.js b/src/traversing.js index 669c70a50..e8a89387d 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -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 ); }; -});
\ No newline at end of file +}); |