Skip to content
Permalink
Browse files

Additional reduction per @Raynos suggestion. Thanks!

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information...
rwaldron committed May 7, 2012
1 parent 2af3642 commit df254d47e43e6e1652b20a3b338b26f634cd2b2a
Showing with 4 additions and 9 deletions.
  1. +4 −9 src/traversing.js
@@ -174,14 +174,9 @@ function isDisconnected( node ) {
return !node || !node.parentNode || node.parentNode.nodeType === 11;
}

function nth( cur, dir ) {
var num = 0;
function sibling( cur, dir ) {
while ( cur = cur[ dir ], cur.nodeType !== 1 ) {}

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

@@ -197,10 +192,10 @@ jQuery.each({
return jQuery.dir( elem, "parentNode", until );
},
next: function( elem ) {
return nth( elem, "nextSibling" );
return sibling( elem, "nextSibling" );
},
prev: function( elem ) {
return nth( elem, "previousSibling" );
return sibling( elem, "previousSibling" );
},
nextAll: function( elem ) {
return jQuery.dir( elem, "nextSibling" );

0 comments on commit df254d4

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