Modify ↓
Ticket #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: | |
| Blocking: | Blocked by: |
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:
| cur === context ) { |
will not work if r.parentNode return null, thus it should be changed to
| cur === context ) { |
Best regards, Laurent
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Fixed http://github.com/jquery/jquery/commit/385ca2aa899d2ed953d9e18c95387e72e330b42c