aboutsummaryrefslogtreecommitdiffstats
path: root/src/jquery
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2007-08-20 02:51:57 +0000
committerJohn Resig <jeresig@gmail.com>2007-08-20 02:51:57 +0000
commit887c00780df75ab42228285e4571b9052e6fd51a (patch)
tree63d14cca64f4a626a910725209824a9566984312 /src/jquery
parent2ef4093cf7f52383dd43bd361864edcda27e5c3c (diff)
downloadjquery-887c00780df75ab42228285e4571b9052e6fd51a.tar.gz
jquery-887c00780df75ab42228285e4571b9052e6fd51a.zip
Implemented the new .slice() method (bug #1517).
Diffstat (limited to 'src/jquery')
-rw-r--r--src/jquery/coreTest.js8
-rw-r--r--src/jquery/jquery.js4
2 files changed, 12 insertions, 0 deletions
diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js
index 289a41610..ff8909c8b 100644
--- a/src/jquery/coreTest.js
+++ b/src/jquery/coreTest.js
@@ -920,3 +920,11 @@ test("eq(), gt(), lt(), contains()", function() {
isSet( $("#ap a").lt(3).get(), q("google", "groups", "anchor1"), "lt()" );
isSet( $("#foo a").contains("log").get(), q("anchor2", "simon"), "contains()" );
});
+
+test("slice()", function() {
+ expect(4);
+ 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)" );
+});
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index b7091e26f..ff33034ed 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -1160,6 +1160,10 @@ jQuery.fn = jQuery.prototype = {
( this.length ? this[0].innerHTML : null ) :
this.empty().append( val );
},
+
+ slice: function() {
+ return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
+ },
/**
* @private