Fix formatting and switch to using the new matchesSelector method in Sizzle.

This commit is contained in:
jeresig 2010-10-10 13:37:36 -04:00
parent 96d8c481b8
commit 6f0b06aa9b

View file

@ -100,23 +100,24 @@ jQuery.fn.extend({
var pos = POS.test( selectors ) ? var pos = POS.test( selectors ) ?
jQuery( selectors, context || this.context ) : null; jQuery( selectors, context || this.context ) : null;
var ret = []; var ret = [];
for ( var i=0,j=this.length; i<j; i++ ) { for ( var i = 0, j = this.length; i < j; i++ ) {
var cur = this[i]; var cur = this[i];
while ( cur ) { while ( cur ) {
if ( pos ? pos.index(cur) > -1 : jQuery.find.matches(selectors, [cur]).length ) { if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
ret.push( cur ); ret.push( cur );
break; break;
} else { } else {
cur = cur.parentNode; cur = cur.parentNode;
if ( !cur.ownerDocument || cur === context ) { if ( !cur.ownerDocument || cur === context ) {
break; break;
} }
} }
} }
} }
ret = ret.length > 1 ? jQuery.unique(ret) : ret; ret = ret.length > 1 ? jQuery.unique(ret) : ret;