Implemented the new .slice() method (bug #1517).
This commit is contained in:
parent
2ef4093cf7
commit
887c00780d
2 changed files with 12 additions and 0 deletions
8
src/jquery/coreTest.js
vendored
8
src/jquery/coreTest.js
vendored
|
@ -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)" );
|
||||||
|
});
|
||||||
|
|
4
src/jquery/jquery.js
vendored
4
src/jquery/jquery.js
vendored
|
@ -1161,6 +1161,10 @@ jQuery.fn = jQuery.prototype = {
|
||||||
this.empty().append( val );
|
this.empty().append( val );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
slice: function() {
|
||||||
|
return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @name domManip
|
* @name domManip
|
||||||
|
|
Loading…
Reference in a new issue