aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVojta Jina2012-02-28 14:43:37 -0800
committerVojta Jina2012-02-28 17:41:30 -0800
commitd656d11489a0dbce0f549b20006052b215c4b500 (patch)
treeb64b201e9dea91cb6e201964525aae9c4d7308c7
parentb37e8a2b141761d3211b52b8b6802c49c92d44f8 (diff)
downloadangular.js-d656d11489a0dbce0f549b20006052b215c4b500.tar.bz2
feat(directive.style): Do not compile content of style element
-rw-r--r--src/AngularPublic.js1
-rw-r--r--src/directives.js6
-rw-r--r--test/directivesSpec.js24
3 files changed, 31 insertions, 0 deletions
diff --git a/src/AngularPublic.js b/src/AngularPublic.js
index a317d4dd..d1ae4a18 100644
--- a/src/AngularPublic.js
+++ b/src/AngularPublic.js
@@ -71,6 +71,7 @@ function publishExternalAPI(angular){
form: ngFormDirective,
script: scriptTemplateLoader,
select: selectDirective,
+ style: styleDirective,
option: optionDirective,
ngBind: ngBindDirective,
ngBindHtml: ngBindHtmlDirective,
diff --git a/src/directives.js b/src/directives.js
index 8a2af704..2d42d3ef 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -969,3 +969,9 @@ var ngTranscludeDirective = valueFn({
});
}]
});
+
+
+var styleDirective = valueFn({
+ restrict: 'E',
+ terminal: true
+});
diff --git a/test/directivesSpec.js b/test/directivesSpec.js
index 88e70b50..c0533745 100644
--- a/test/directivesSpec.js
+++ b/test/directivesSpec.js
@@ -557,4 +557,28 @@ describe("directive", function() {
expect(element.hasClass('bar')).toBe(true);
}));
});
+
+
+ describe('style', function() {
+
+ it('should not compile style element', inject(function($compile, $rootScope) {
+ element = jqLite('<style type="text/css">should {{notBound}}</style>');
+ $compile(element)($rootScope);
+ $rootScope.$digest();
+
+ // read innerHTML and trim to pass on IE8
+ expect(trim(element[0].innerHTML)).toBe('should {{notBound}}');
+ }));
+
+
+ it('should compile content of element with style attr', inject(function($compile, $rootScope) {
+ element = jqLite('<div style="some">{{bind}}</div>');
+ $compile(element)($rootScope);
+ $rootScope.$apply(function() {
+ $rootScope.bind = 'value';
+ });
+
+ expect(element.text()).toBe('value');
+ }));
+ });
});