diff options
| author | Gonzalo Ruiz de Villa | 2013-05-02 13:05:22 +0200 | 
|---|---|---|
| committer | Pete Bacon Darwin | 2013-05-02 15:12:37 +0100 | 
| commit | 6452707d4098235bdbde34e790aee05a1b091218 (patch) | |
| tree | 01897f4f65d26e12a8dcf5367eb020745a2ef82b /test | |
| parent | dc9a580617a838b63cbf5feae362b6f9cf5ed986 (diff) | |
| download | angular.js-6452707d4098235bdbde34e790aee05a1b091218.tar.bz2 | |
fix($rootScope) ensure $watchCollection correctly handles arrayLike objects
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/rootScopeSpec.js | 17 | 
1 files changed, 17 insertions, 0 deletions
| diff --git a/test/ng/rootScopeSpec.js b/test/ng/rootScopeSpec.js index cd8d4109..cac7c160 100644 --- a/test/ng/rootScopeSpec.js +++ b/test/ng/rootScopeSpec.js @@ -463,6 +463,23 @@ describe('Scope', function() {            $rootScope.$digest();            expect(log).toEqual([ '[{},[]]' ]);          }); + +        it('should watch array-like objects like arrays', function () { +          var arrayLikelog = []; +          $rootScope.$watchCollection('arrayLikeObject', function logger(obj) { +            forEach(obj, function (element){ +              arrayLikelog.push(element.name); +            }) +          }); +          document.body.innerHTML = "<p>" + +                                      "<a name='x'>a</a>" + +                                      "<a name='y'>b</a>" + +                                    "</p>"; + +          $rootScope.arrayLikeObject =  document.getElementsByTagName('a') +          $rootScope.$digest(); +          expect(arrayLikelog).toEqual(['x', 'y']); +        });        }); | 
