]> source.dussan.org Git - jquery.git/commitdiff
Remove unnecessary arguments from .nth(). Fixes #11720 769/head
authorSindre Sorhus <sindresorhus@gmail.com>
Mon, 7 May 2012 17:59:11 +0000 (19:59 +0200)
committerSindre Sorhus <sindresorhus@gmail.com>
Mon, 7 May 2012 17:59:11 +0000 (19:59 +0200)
Also use postfix increment to make it a little clearer.

src/traversing.js

index 2e45aade7ab6e157e9c05250ef0d4dd7d46842b6..0b8a5f24051731201afb3f22f72261e7f082f1b5 100644 (file)
@@ -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;
                        }
                }