From 5f5d4feadbfa9d8ecc8150041dfd2bca2b2e9fea Mon Sep 17 00:00:00 2001 From: Per RovegÄrd Date: Sat, 16 Feb 2013 00:32:38 +0100 Subject: 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 --- test/ng/directive/ngClassSpec.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') 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('
')($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('