Skip to content
Permalink
Browse files

Fix #11738. Remove deprecated .closest(Array) => Array.

  • Loading branch information
dmethvin committed May 11, 2012
1 parent c5fda29 commit 56d5c1c3a3b012b159e56acbb655a14abfcc8894
Showing with 1 addition and 33 deletions.
  1. +1 −21 src/traversing.js
  2. +0 −12 test/unit/traversing.js
@@ -84,28 +84,8 @@ jQuery.fn.extend({
},

closest: function( selectors, context ) {
var ret = [], i, l, cur = this[0];
var ret = [], i, l, cur;

// Array (deprecated as of jQuery 1.7)
if ( jQuery.isArray( selectors ) ) {
var level = 1;

while ( cur && cur.ownerDocument && cur !== context ) {
for ( i = 0; i < selectors.length; i++ ) {

if ( jQuery( cur ).is( selectors[ i ] ) ) {
ret.push({ selector: selectors[ i ], elem: cur, level: level });
}
}

cur = cur.parentNode;
level++;
}

return ret;
}

// String
var pos = POS.test( selectors ) || typeof selectors !== "string" ?
jQuery( selectors, context || this.context ) :
0;
@@ -299,18 +299,6 @@ test("closest()", function() {
equal( jQuery("<div>text</div>").closest("[lang]").length, 0, "Disconnected nodes with text and non-existent attribute selector" );
});

test("closest(Array)", function() {
expect(7);
deepEqual( jQuery("body").closest(["body"]), [{selector:"body", elem:document.body, level:1}], "closest([body])" );
deepEqual( jQuery("body").closest(["html"]), [{selector:"html", elem:document.documentElement, level:2}], "closest([html])" );
deepEqual( jQuery("body").closest(["div"]), [], "closest([div])" );
deepEqual( jQuery("#yahoo").closest(["div"]), [{"selector":"div", "elem": document.getElementById("foo"), "level": 3}, { "selector": "div", "elem": document.getElementById("qunit-fixture"), "level": 4 }], "closest([div])" );
deepEqual( jQuery("#qunit-fixture").closest(["span,#html"]), [{selector:"span,#html", elem:document.documentElement, level:4}], "closest([span,#html])" );

deepEqual( jQuery("body").closest(["body","html"]), [{selector:"body", elem:document.body, level:1}, {selector:"html", elem:document.documentElement, level:2}], "closest([body, html])" );
deepEqual( jQuery("body").closest(["span","html"]), [{selector:"html", elem:document.documentElement, level:2}], "closest([body, html])" );
});

test("closest(jQuery)", function() {
expect(8);
var $child = jQuery("#nothiddendivchild"),

0 comments on commit 56d5c1c

Please sign in to comment.
You can’t perform that action at this time.