aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/rootScopeSpec.js
diff options
context:
space:
mode:
authorGonzalo Ruiz de Villa2013-05-02 13:05:22 +0200
committerPete Bacon Darwin2013-05-02 15:12:37 +0100
commit6452707d4098235bdbde34e790aee05a1b091218 (patch)
tree01897f4f65d26e12a8dcf5367eb020745a2ef82b /test/ng/rootScopeSpec.js
parentdc9a580617a838b63cbf5feae362b6f9cf5ed986 (diff)
downloadangular.js-6452707d4098235bdbde34e790aee05a1b091218.tar.bz2
fix($rootScope) ensure $watchCollection correctly handles arrayLike objects
Diffstat (limited to 'test/ng/rootScopeSpec.js')
-rw-r--r--test/ng/rootScopeSpec.js17
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']);
+ });
});