aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng
diff options
context:
space:
mode:
authorPer RovegÄrd2013-02-16 00:32:38 +0100
committerIgor Minar2013-02-18 20:35:40 -0800
commit2aa212b19c71df82287b4b074da3ab14cbf37348 (patch)
treeae1d889495a61d075b90d9be32736435092a10f5 /test/ng
parent1f23cfe9c751f84d9fc996df6d54961b2e46e868 (diff)
downloadangular.js-2aa212b19c71df82287b4b074da3ab14cbf37348.tar.bz2
fix(ngClass): keep track of old ngClass value manually
ngClassWatchAction, when called as a $watch function, gets the wrong old value after it has been invoked previously due to observation of the interpolated class attribute. As a result it doesn't remove classes properly. Keeping track of the old value manually seems to fix this. Closes #1637
Diffstat (limited to 'test/ng')
-rw-r--r--test/ng/directive/ngClassSpec.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ng/directive/ngClassSpec.js b/test/ng/directive/ngClassSpec.js
index 4a53030b..69afef7a 100644
--- a/test/ng/directive/ngClassSpec.js
+++ b/test/ng/directive/ngClassSpec.js
@@ -236,6 +236,17 @@ describe('ngClass', function() {
}));
+ it('should not mess up class value due to observing an interpolated class attribute', inject(function($rootScope, $compile) {
+ $rootScope.foo = true;
+ $rootScope.$watch("anything", function() {
+ $rootScope.foo = false;
+ });
+ element = $compile('<div ng-class="{foo:foo}"></div>')($rootScope);
+ $rootScope.$digest();
+ expect(element.hasClass('foo')).toBe(false);
+ }));
+
+
it('should update ngClassOdd/Even when model is changed by filtering', inject(function($rootScope, $compile) {
element = $compile('<ul>' +
'<li ng-repeat="i in items" ' +