X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Ftraversing.js;h=0e379c72b0591092254182cc5ca07a6ec0745b84;hb=c4f144eeffd94c745839b0ced2de9c62cfa9f075;hp=f46820f849d913a3fe95942eb58c52d31d5d1ca8;hpb=d6991fa273515a8503692324499edcc71b5c3f64;p=jquery.git diff --git a/src/traversing.js b/src/traversing.js index f46820f..0e379c7 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -1,4 +1,4 @@ -jQuery.winnow = function( elements, qualifier, keep ) { +var winnow = function( elements, qualifier, keep ) { if(jQuery.isFunction( qualifier )) { return jQuery.grep(elements, function(elem, i) { return !!qualifier.call( elem, i ) === keep; @@ -44,11 +44,11 @@ jQuery.fn.extend({ }, not: function( selector ) { - return this.pushStack( jQuery.winnow(this, selector, false), "not", selector); + return this.pushStack( winnow(this, selector, false), "not", selector); }, filter: function( selector ) { - return this.pushStack( jQuery.winnow(this, selector, true), "filter", selector ); + return this.pushStack( winnow(this, selector, true), "filter", selector ); }, closest: function( selector, context ) { @@ -78,7 +78,17 @@ jQuery.fn.extend({ }, eq: function( i ) { - return this.slice( i, +i + 1 ); + return i === -1 ? + this.slice( i ) : + this.slice( i, +i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); }, slice: function() {