diff options
| author | Vojta Jina | 2012-03-19 17:26:05 -0700 |
|---|---|---|
| committer | Vojta Jina | 2012-03-20 10:39:43 -0700 |
| commit | f49eaf8bf2df5f4e0e82d6c89e849a4f82c8d414 (patch) | |
| tree | c2e62392ed85027c37d8cf2b41def77804fc1135 /test/service/compilerSpec.js | |
| parent | f701ce08f9d63be05fc3b92f57ad473e1e749b2d (diff) | |
| download | angular.js-f49eaf8bf2df5f4e0e82d6c89e849a4f82c8d414.tar.bz2 | |
fix($compile): Merge interpolated css class when replacing an element
Diffstat (limited to 'test/service/compilerSpec.js')
| -rw-r--r-- | test/service/compilerSpec.js | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/test/service/compilerSpec.js b/test/service/compilerSpec.js index f977294b..a95e9eb3 100644 --- a/test/service/compilerSpec.js +++ b/test/service/compilerSpec.js @@ -391,7 +391,7 @@ describe('$compile', function() { })); - it('should merge attributes', inject(function($compile, $rootScope) { + it('should merge attributes including style attr', inject(function($compile, $rootScope) { element = $compile( '<div><div replace class="medium-log" style="height: 20px" ></div><div>') ($rootScope); @@ -431,6 +431,39 @@ describe('$compile', function() { $rootScope.$digest(); expect(element.text()).toEqual('Hello: 1; Hello: 2; '); })); + + + it('should merge interpolated css class', inject(function($compile, $rootScope) { + element = $compile('<div class="one {{cls}} three" replace></div>')($rootScope); + + $rootScope.$apply(function() { + $rootScope.cls = 'two'; + }); + + expect(element).toHaveClass('one'); + expect(element).toHaveClass('two'); // interpolated + expect(element).toHaveClass('three'); + expect(element).toHaveClass('log'); // merged from replace directive template + })); + + + it('should merge interpolated css class with ng-repeat', + inject(function($compile, $rootScope) { + element = $compile( + '<div>' + + '<div ng-repeat="i in [1]" class="one {{cls}} three" replace></div>' + + '</div>')($rootScope); + + $rootScope.$apply(function() { + $rootScope.cls = 'two'; + }); + + var child = element.find('div').eq(0); + expect(child).toHaveClass('one'); + expect(child).toHaveClass('two'); // interpolated + expect(child).toHaveClass('three'); + expect(child).toHaveClass('log'); // merged from replace directive template + })); }); |
