diff options
author | John Resig <jeresig@gmail.com> | 2007-09-15 03:08:46 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2007-09-15 03:08:46 +0000 |
commit | 3dabd7ec301770a2a6bb8457c96d630d42376719 (patch) | |
tree | 9d039737cbe255513780b5aca2b0da711f010595 | |
parent | 1088d06e5485451549990e6143001488f1580d83 (diff) | |
download | jquery-3dabd7ec301770a2a6bb8457c96d630d42376719.tar.gz jquery-3dabd7ec301770a2a6bb8457c96d630d42376719.zip |
Added .eq(Number) back in - I'm convinced that it's more useful than the .slice() replacement. lt/gt are still gone, though.
-rw-r--r-- | src/core.js | 4 | ||||
-rw-r--r-- | test/unit/core.js | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/core.js b/src/core.js index 06d2fd7b5..d059564fe 100644 --- a/src/core.js +++ b/src/core.js @@ -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 ) ); }, diff --git a/test/unit/core.js b/test/unit/core.js index dce86d828..818e0f7d5 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -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() { |