aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSekib Omazic2014-02-28 12:39:10 +0100
committerIgor Minar2014-03-06 02:19:30 -0800
commit0609453e1f9ae074f8d786df903096a6eadb6aa0 (patch)
tree757c5603929cb7931f7b08657446f89471ab1f38 /test
parent7682e5747a889d7818f5ce9ebb2bdb8bf3897c34 (diff)
downloadangular.js-0609453e1f9ae074f8d786df903096a6eadb6aa0.tar.bz2
fix(style): expressions in style tags
Enable data-binding for style tags. Note: this feature does not work on IE8. Closes #2387 Closes #6492
Diffstat (limited to 'test')
-rw-r--r--test/ng/directive/styleSpec.js58
1 files changed, 55 insertions, 3 deletions
diff --git a/test/ng/directive/styleSpec.js b/test/ng/directive/styleSpec.js
index bdc4ea85..36f15cde 100644
--- a/test/ng/directive/styleSpec.js
+++ b/test/ng/directive/styleSpec.js
@@ -9,13 +9,65 @@ describe('style', function() {
});
- it('should not compile style element', inject(function($compile, $rootScope) {
- element = jqLite('<style type="text/css">should {{notBound}}</style>');
+ it('should compile style element without binding', inject(function($compile, $rootScope) {
+ element = jqLite('<style type="text/css">.header{font-size:1.5em; h3{font-size:1.5em}}</style>');
$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('<style type="text/css">.some-container{ width: {{elementWidth}}px; }</style>');
+ $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('<style type="text/css">.header{ h3 { font-size: {{fontSize}}em }}</style>');
+ $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('<style type="text/css">.header{ h3 { font-size: {{fontSize}}{{unit}} }}</style>');
+ $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 }}');
}));