aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSindre Sorhus <sindresorhus@gmail.com>2012-05-07 19:59:11 +0200
committerSindre Sorhus <sindresorhus@gmail.com>2012-05-07 19:59:11 +0200
commit4de7b5412e33331ca6f9f8a2d6e5e00dec7299f2 (patch)
treeaadf363826767428768c5556578c1fba9ff3b737
parent169b4185bcd34803b4459cb564c04e72bd4ddf1e (diff)
downloadjquery-4de7b5412e33331ca6f9f8a2d6e5e00dec7299f2.tar.gz
jquery-4de7b5412e33331ca6f9f8a2d6e5e00dec7299f2.zip
Remove unnecessary arguments from .nth(). Fixes #11720
Also use postfix increment to make it a little clearer.
-rw-r--r--src/traversing.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/traversing.js b/src/traversing.js
index 2e45aade7..0b8a5f240 100644
--- a/src/traversing.js
+++ b/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;
}
}