Skip to content

Commit

Permalink
Further reduce historical cruft. Removes the untested and unnec. jQue…
Browse files Browse the repository at this point in the history
…ry.nth()

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed May 7, 2012
1 parent fbee36b commit 2af3642
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/traversing.js
Expand Up @@ -174,6 +174,17 @@ function isDisconnected( node ) {
return !node || !node.parentNode || node.parentNode.nodeType === 11;
}

function nth( cur, dir ) {
var num = 0;

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

jQuery.each({
parent: function( elem ) {
var parent = elem.parentNode;
Expand All @@ -186,10 +197,10 @@ jQuery.each({
return jQuery.dir( elem, "parentNode", until );
},
next: function( elem ) {
return jQuery.nth( elem, "nextSibling" );
return nth( elem, "nextSibling" );
},
prev: function( elem ) {
return jQuery.nth( elem, "previousSibling" );
return nth( elem, "previousSibling" );
},
nextAll: function( elem ) {
return jQuery.dir( elem, "nextSibling" );
Expand Down Expand Up @@ -260,18 +271,6 @@ jQuery.extend({
return matched;
},

nth: function( cur, dir ) {
var num = 0;

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

return cur;
},

sibling: function( n, elem ) {
var r = [];

Expand Down

0 comments on commit 2af3642

Please sign in to comment.