Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8798

Show
Ignore:
Timestamp:
02/03/08 21:08:13 (7 months ago)
Author:
tobie
Message:

prototype: Prevent Enumerable#eachSlice from entering into an endless loop if passed an argument smaller than 1. Closes #10665.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/trunk/CHANGELOG

    r8797 r8798  
     1* Prevent Enumerable#eachSlice from entering into an endless loop if passed an argument smaller than 1. Closes #10665. [kangax, Tobie Langel] 
     2 
    13* Allow Selector to correctly detect the presence of namespaced attributes. Closes #10987. [Samuel Lebeau, Tobie Langel] 
    24 
  • spinoffs/prototype/trunk/src/enumerable.js

    r8149 r8798  
    1818    iterator = iterator ? iterator.bind(context) : Prototype.K; 
    1919    var index = -number, slices = [], array = this.toArray(); 
     20    if (number < 1) return array; 
    2021    while ((index += number) < array.length) 
    2122      slices.push(array.slice(index, index+number)); 
  • spinoffs/prototype/trunk/test/unit/enumerable.html

    r8572 r8798  
    165165        Fixtures.Primes.eachSlice( 3, function(slice){ return slice.reverse() }).flatten() 
    166166      ); 
     167      assertEnumEqual(Fixtures.Basic, Fixtures.Basic.eachSlice(-10)); 
     168      assertEnumEqual(Fixtures.Basic, Fixtures.Basic.eachSlice(0)); 
     169      assertNotIdentical(Fixtures.Basic, Fixtures.Basic.eachSlice(0)); 
    167170    }}, 
    168171