prototype: Prevent Enumerable#eachSlice from entering into an endless loop if passed an argument smaller than 1. Closes #10665.
This commit is contained in:
parent
f4d68350f3
commit
d770a6c704
|
@ -1,3 +1,5 @@
|
|||
* Prevent Enumerable#eachSlice from entering into an endless loop if passed an argument smaller than 1. Closes #10665. [kangax, Tobie Langel]
|
||||
|
||||
* Allow Selector to correctly detect the presence of namespaced attributes. Closes #10987. [Samuel Lebeau, Tobie Langel]
|
||||
|
||||
* Make Element#absolutize and Element#relativize always return element. Closes #10983. [kangax]
|
||||
|
|
|
@ -17,6 +17,7 @@ var Enumerable = {
|
|||
eachSlice: function(number, iterator, context) {
|
||||
iterator = iterator ? iterator.bind(context) : Prototype.K;
|
||||
var index = -number, slices = [], array = this.toArray();
|
||||
if (number < 1) return array;
|
||||
while ((index += number) < array.length)
|
||||
slices.push(array.slice(index, index+number));
|
||||
return slices.collect(iterator, context);
|
||||
|
|
|
@ -164,6 +164,9 @@
|
|||
[3, 2, 1, 11, 7, 5, 19, 17, 13, 31, 29, 23, 43, 41, 37, 59, 53, 47, 71, 67, 61, 83, 79, 73, 97, 89],
|
||||
Fixtures.Primes.eachSlice( 3, function(slice){ return slice.reverse() }).flatten()
|
||||
);
|
||||
assertEnumEqual(Fixtures.Basic, Fixtures.Basic.eachSlice(-10));
|
||||
assertEnumEqual(Fixtures.Basic, Fixtures.Basic.eachSlice(0));
|
||||
assertNotIdentical(Fixtures.Basic, Fixtures.Basic.eachSlice(0));
|
||||
}},
|
||||
|
||||
testEachWithIndex: function() {with(this) {
|
||||
|
|
Loading…
Reference in New Issue