aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2010-09-27 20:59:42 -0400
committerjeresig <jeresig@gmail.com>2010-09-27 20:59:42 -0400
commit7be11207b9267592a639eb739dc8d719c7de56a1 (patch)
tree231d3f1010c8d457888983c6fbe196e771d3f64d /src
parent8c41325a081f4009aa94748b9b6045e50a78422e (diff)
downloadjquery-7be11207b9267592a639eb739dc8d719c7de56a1.tar.gz
jquery-7be11207b9267592a639eb739dc8d719c7de56a1.zip
Removing unique check on closest(Array) (it wasn't appropriate there and broke functionality elsewhere) - follow-up to commit 8c41325a081f4009aa94748b9b6045e50a78422e. Also added another test for closest(Array) after a discussion with @jitter in 26b0e913dda386b6b2848196689a02a2da6aa40d.
Diffstat (limited to 'src')
-rw-r--r--src/traversing.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/traversing.js b/src/traversing.js
index f7dde44ec..dff108754 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -56,9 +56,11 @@ jQuery.fn.extend({
closest: function( selectors, context ) {
var ret;
+
if ( jQuery.isArray( selectors ) ) {
var cur = this[0], match, matches = {}, selector, level = 1;
ret = [];
+
if ( cur && selectors.length ) {
for ( var i = 0, l = selectors.length; i < l; i++ ) {
selector = selectors[i];
@@ -78,23 +80,27 @@ jQuery.fn.extend({
ret.push({ selector: selector, elem: cur, level: level });
}
}
+
cur = cur.parentNode;
level++;
}
}
- return ret.length > 1 ? jQuery.unique(ret) : ret;
+ return ret;
}
var pos = jQuery.expr.match.POS.test( selectors ) ?
jQuery( selectors, context || this.context ) : null;
+
ret = jQuery.map(this.get(),function( cur,i ) {
while ( cur && cur.ownerDocument && cur !== context ) {
if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
return cur;
}
+
cur = cur.parentNode;
}
+
return null;
});