Skip to content
Permalink
Browse files

Remove unnecessary arguments from .nth(). Fixes #11720

Also use postfix increment to make it a little clearer.
  • Loading branch information...
sindresorhus committed May 7, 2012
1 parent 169b418 commit 4de7b5412e33331ca6f9f8a2d6e5e00dec7299f2
Showing with 4 additions and 5 deletions.
  1. +4 −5 src/traversing.js
@@ -186,10 +186,10 @@ jQuery.each({
return jQuery.dir( elem, "parentNode", until );
},
next: function( elem ) {
return jQuery.nth( elem, 2, "nextSibling" );
return jQuery.nth( elem, "nextSibling" );
},
prev: function( elem ) {
return jQuery.nth( elem, 2, "previousSibling" );
return jQuery.nth( elem, "previousSibling" );
},
nextAll: function( elem ) {
return jQuery.dir( elem, "nextSibling" );
@@ -260,12 +260,11 @@ jQuery.extend({
return matched;
},

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

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

0 comments on commit 4de7b54

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