]> source.dussan.org Git - jquery.git/commitdiff
Added .eq(Number) back in - I'm convinced that it's more useful than the .slice(...
authorJohn Resig <jeresig@gmail.com>
Sat, 15 Sep 2007 03:08:46 +0000 (03:08 +0000)
committerJohn Resig <jeresig@gmail.com>
Sat, 15 Sep 2007 03:08:46 +0000 (03:08 +0000)
src/core.js
test/unit/core.js

index 06d2fd7b5161e42b0527ceecee8da0e54873f462..d059564fe02aa19cf2938319c7ba8bda931307f8 100644 (file)
@@ -363,6 +363,10 @@ jQuery.fn = jQuery.prototype = {
                return this.after( val ).remove();
        },
 
+       eq: function(i){
+               return this.slice(i, i+1);
+       },
+
        slice: function() {
                return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
        },
index dce86d828e2b18554a67beeca3e3714bf7c6c13b..818e0f7d55dec03bd42c2e35ab277ac87d967d73 100644 (file)
@@ -1034,11 +1034,13 @@ test("empty()", function() {
 });
 
 test("slice()", function() {
-       expect(4);
+       expect(5);
        isSet( $("#ap a").slice(1,2), q("groups"), "slice(1,2)" );
        isSet( $("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" );
        isSet( $("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" );
        isSet( $("#ap a").slice(-1), q("mark"), "slice(-1)" );
+
+       isSet( $("#ap a").eq(1), q("groups"), "eq(1)" );
 });
 
 test("map()", function() {