Skip to content

Commit

Permalink
Remove unnecessary arguments from .nth(). Fixes #11720
Browse files Browse the repository at this point in the history
Also use postfix increment to make it a little clearer.
  • Loading branch information
sindresorhus committed May 7, 2012
1 parent 169b418 commit 4de7b54
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/traversing.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ jQuery.each({
return jQuery.dir( elem, "parentNode", until ); return jQuery.dir( elem, "parentNode", until );
}, },
next: function( elem ) { next: function( elem ) {
return jQuery.nth( elem, 2, "nextSibling" ); return jQuery.nth( elem, "nextSibling" );
}, },
prev: function( elem ) { prev: function( elem ) {
return jQuery.nth( elem, 2, "previousSibling" ); return jQuery.nth( elem, "previousSibling" );
}, },
nextAll: function( elem ) { nextAll: function( elem ) {
return jQuery.dir( elem, "nextSibling" ); return jQuery.dir( elem, "nextSibling" );
Expand Down Expand Up @@ -260,12 +260,11 @@ jQuery.extend({
return matched; return matched;
}, },


nth: function( cur, result, dir, elem ) { nth: function( cur, dir ) {
result = result || 1;
var num = 0; var num = 0;


for ( ; cur; cur = cur[dir] ) { for ( ; cur; cur = cur[dir] ) {
if ( cur.nodeType === 1 && ++num === result ) { if ( cur.nodeType === 1 && num++ === 1 ) {
break; break;
} }
} }
Expand Down

0 comments on commit 4de7b54

Please sign in to comment.