mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-04 08:58:16 +08:00
feat(directive.style): Do not compile content of style element
This commit is contained in:
@@ -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');
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user