feat(directive.style): Do not compile content of style element

This commit is contained in:
Vojta Jina 2012-02-28 14:43:37 -08:00
parent b37e8a2b14
commit d656d11489
3 changed files with 31 additions and 0 deletions

View file

@ -71,6 +71,7 @@ function publishExternalAPI(angular){
form: ngFormDirective,
script: scriptTemplateLoader,
select: selectDirective,
style: styleDirective,
option: optionDirective,
ngBind: ngBindDirective,
ngBindHtml: ngBindHtmlDirective,

View file

@ -969,3 +969,9 @@ var ngTranscludeDirective = valueFn({
});
}]
});
var styleDirective = valueFn({
restrict: 'E',
terminal: true
});

View file

@ -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');
}));
});
});