diff options
| author | Gonzalo Ruiz de Villa | 2013-05-01 01:19:44 +0200 | 
|---|---|---|
| committer | Pete Bacon Darwin | 2013-05-02 15:12:37 +0100 | 
| commit | 1d8e11ddfbd6b08ff02df4331f6df125f49da3dc (patch) | |
| tree | 611603eca5b1ff4db46230a0159a98d5e8487048 /test | |
| parent | 6452707d4098235bdbde34e790aee05a1b091218 (diff) | |
| download | angular.js-1d8e11ddfbd6b08ff02df4331f6df125f49da3dc.tar.bz2 | |
fix(ngRepeat): correctly iterate over array-like objects
Check if the object is array-like to iterate over it like it's done with arrays.
Closes #2546
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/directive/ngRepeatSpec.js | 20 | 
1 files changed, 20 insertions, 0 deletions
| diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index fbd1a2dc..ac1ce7e7 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -55,6 +55,26 @@ describe('ngRepeat', function() {    }); +  it('should iterate over an array-like object', function() { +    element = $compile( +      '<ul>' + +        '<li ng-repeat="item in items">{{item.name}};</li>' + +      '</ul>')(scope); + +    document.body.innerHTML = "<p>" + +                                      "<a name='x'>a</a>" + +                                      "<a name='y'>b</a>" + +                                      "<a name='x'>c</a>" + +                                    "</p>"; + +    var htmlCollection = document.getElementsByTagName('a') +    scope.items = htmlCollection; +    scope.$digest(); +    expect(element.find('li').length).toEqual(3); +    expect(element.text()).toEqual('x;y;x;'); +  }); + +    it('should iterate over on object/map', function() {      element = $compile(        '<ul>' + | 
