Skip to content
Permalink
Browse files

Fix formatting and switch to using the new matchesSelector method in …

…Sizzle.
  • Loading branch information...
jeresig committed Oct 10, 2010
1 parent 96d8c48 commit 6f0b06aa9b467096ae781cf33f18fa925923cf6f
Showing with 14 additions and 13 deletions.
  1. +14 −13 src/traversing.js
@@ -100,23 +100,24 @@ jQuery.fn.extend({
var pos = POS.test( selectors ) ?
jQuery( selectors, context || this.context ) : null;

var ret = [];
var ret = [];

for ( var i=0,j=this.length; i<j; i++ ) {
var cur = this[i];
for ( var i = 0, j = this.length; i < j; i++ ) {
var cur = this[i];

while ( cur ) {
if ( pos ? pos.index(cur) > -1 : jQuery.find.matches(selectors, [cur]).length ) {
while ( cur ) {
if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
ret.push( cur );
break;
break;

} else {
cur = cur.parentNode;
if ( !cur.ownerDocument || cur === context ) {
break;
}
}
}
}
cur = cur.parentNode;
if ( !cur.ownerDocument || cur === context ) {

This comment has been minimized.

Copy link
@maranomynet

maranomynet Oct 11, 2010

you need to check for the existence of cur, like so:
if ( !cur || !cur.ownerDocument || cur === context ) {

Otherwise the following piece of code triggers error on this line...

jQuery('<div><p><b><i/></b></p></div>').find('i').closest('table');

This comment has been minimized.

Copy link
@jeresig
break;
}
}
}
}

ret = ret.length > 1 ? jQuery.unique(ret) : ret;

0 comments on commit 6f0b06a

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