Bug Tracker

Opened 9 years ago

Closed 9 years ago

#7142 closed bug (fixed)

Closest() is broken in 1.4.3

Reported by: lcr Owned by:
Priority: blocker Milestone: 1.4.3
Component: traversing Version: 1.4.2
Keywords: closest broken Cc:
Blocked by: Blocking:

Description

The closest method ends in the following loop:

for ( i = 0, l = this.length; i < l; i++ ) {

cur = this[i];

while ( cur ) {

if ( pos ? pos.index(cur) > -1 :

jQuery.find.matchesSelector(cur, selectors) ) {

ret.push( cur ); break;

} else {

cur = r.parentNode;

if (!cur.ownerDocument
cur === context ) {

break;

}

}

}

} the following line:

if (!cur.ownerDocument
cur === context ) {

will not work if r.parentNode return null, thus it should be changed to

if (cur && !cur.ownerDocument
cur === context ) {

Best regards, Laurent

Change History (1)

comment:1 Changed 9 years ago by john

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.