diff --git a/src/ng/directive/style.js b/src/ng/directive/style.js index 68ea1465f109..1e700aab3ddd 100644 --- a/src/ng/directive/style.js +++ b/src/ng/directive/style.js @@ -2,5 +2,5 @@ var styleDirective = valueFn({ restrict: 'E', - terminal: true + terminal: false }); diff --git a/test/ng/directive/styleSpec.js b/test/ng/directive/styleSpec.js index bdc4ea858bf8..665819fcf419 100644 --- a/test/ng/directive/styleSpec.js +++ b/test/ng/directive/styleSpec.js @@ -9,15 +9,63 @@ describe('style', function() { }); - it('should not compile style element', inject(function($compile, $rootScope) { - element = jqLite(''); + it('should compile style element without binding', inject(function($compile, $rootScope) { + element = jqLite(''); $compile(element)($rootScope); $rootScope.$digest(); // read innerHTML and trim to pass on IE8 - expect(trim(element[0].innerHTML)).toBe('should {{notBound}}'); + expect(trim(element[0].innerHTML)).toBe('.header{font-size:1.5em; h3{font-size:1.5em}}'); })); + it('should compile style element with one simple bind', inject(function($compile, $rootScope) { + element = jqLite(''); + $compile(element)($rootScope); + $rootScope.$digest(); + + // read innerHTML and trim to pass on IE8 + expect(trim(element[0].innerHTML)).toBe('.some-container{ width: px; }'); + + $rootScope.$apply(function() { + $rootScope.elementWidth = 200; + }); + + // read innerHTML and trim to pass on IE8 + expect(trim(element[0].innerHTML)).toBe('.some-container{ width: 200px; }'); + })); + + it('should compile style element with one bind', inject(function($compile, $rootScope) { + element = jqLite(''); + $compile(element)($rootScope); + $rootScope.$digest(); + + // read innerHTML and trim to pass on IE8 + expect(trim(element[0].innerHTML)).toBe('.header{ h3 { font-size: em }}'); + + $rootScope.$apply(function() { + $rootScope.fontSize = 1.5; + }); + + // read innerHTML and trim to pass on IE8 + expect(trim(element[0].innerHTML)).toBe('.header{ h3 { font-size: 1.5em }}'); + })); + + it('should compile style element with two binds', inject(function($compile, $rootScope) { + element = jqLite(''); + $compile(element)($rootScope); + $rootScope.$digest(); + + // read innerHTML and trim to pass on IE8 + expect(trim(element[0].innerHTML)).toBe('.header{ h3 { font-size: }}'); + + $rootScope.$apply(function() { + $rootScope.fontSize = 1.5; + $rootScope.unit = 'em'; + }); + + // read innerHTML and trim to pass on IE8 + expect(trim(element[0].innerHTML)).toBe('.header{ h3 { font-size: 1.5em }}'); + })); it('should compile content of element with style attr', inject(function($compile, $rootScope) { element = jqLite('