diff options
| author | Daniel Herman | 2013-07-25 23:15:57 -0400 |
|---|---|---|
| committer | Ken Sheedlo | 2013-07-31 11:08:56 -0700 |
| commit | fad626f3047cd4ff31fe7a4181ca63f275adbae6 (patch) | |
| tree | 28b4ee89d0cbe8867c84d000243463586e409415 /test/ng/directive/ngRepeatSpec.js | |
| parent | 000012f3196776bb1d4b5df802c6763e514c0fb9 (diff) | |
| download | angular.js-fad626f3047cd4ff31fe7a4181ca63f275adbae6.tar.bz2 | |
fix(isArrayLike) Correctly detect arrayLike items
Change the implementation of isArrayLike to use one heavily based on the
implementation in jQuery in order to correctly detect array-like
objects, that way functionality like ngRepeat works as expected.
Diffstat (limited to 'test/ng/directive/ngRepeatSpec.js')
| -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 a85fd5ab..9dfaa404 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -77,7 +77,27 @@ describe('ngRepeat', function() { expect(element.find('li').length).toEqual(3); expect(element.text()).toEqual('x;y;x;'); }); + + it('should iterate over an array-like class', function() { + function Collection() {} + Collection.prototype = new Array(); + Collection.prototype.length = 0; + var collection = new Collection(); + collection.push({ name: "x" }); + collection.push({ name: "y" }); + collection.push({ name: "z" }); + + element = $compile( + '<ul>' + + '<li ng-repeat="item in items">{{item.name}};</li>' + + '</ul>')(scope); + + scope.items = collection; + scope.$digest(); + expect(element.find('li').length).toEqual(3); + expect(element.text()).toEqual('x;y;z;'); + }); it('should iterate over on object/map', function() { element = $compile( |
