mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
feat(directive.style): Do not compile content of style element
This commit is contained in:
parent
b37e8a2b14
commit
d656d11489
3 changed files with 31 additions and 0 deletions
|
|
@ -71,6 +71,7 @@ function publishExternalAPI(angular){
|
|||
form: ngFormDirective,
|
||||
script: scriptTemplateLoader,
|
||||
select: selectDirective,
|
||||
style: styleDirective,
|
||||
option: optionDirective,
|
||||
ngBind: ngBindDirective,
|
||||
ngBindHtml: ngBindHtmlDirective,
|
||||
|
|
|
|||
|
|
@ -969,3 +969,9 @@ var ngTranscludeDirective = valueFn({
|
|||
});
|
||||
}]
|
||||
});
|
||||
|
||||
|
||||
var styleDirective = valueFn({
|
||||
restrict: 'E',
|
||||
terminal: true
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue