Commit 887c0078 authored by John Resig's avatar John Resig

Implemented the new .slice() method (bug #1517).

parent 2ef4093c
...@@ -920,3 +920,11 @@ test("eq(), gt(), lt(), contains()", function() { ...@@ -920,3 +920,11 @@ test("eq(), gt(), lt(), contains()", function() {
isSet( $("#ap a").lt(3).get(), q("google", "groups", "anchor1"), "lt()" ); isSet( $("#ap a").lt(3).get(), q("google", "groups", "anchor1"), "lt()" );
isSet( $("#foo a").contains("log").get(), q("anchor2", "simon"), "contains()" ); 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)" );
});
...@@ -1160,6 +1160,10 @@ jQuery.fn = jQuery.prototype = { ...@@ -1160,6 +1160,10 @@ jQuery.fn = jQuery.prototype = {
( this.length ? this[0].innerHTML : null ) : ( this.length ? this[0].innerHTML : null ) :
this.empty().append( val ); this.empty().append( val );
}, },
slice: function() {
return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
},
/** /**
* @private * @private
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment