Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit d656d11

Browse files
committed
feat(directive.style): Do not compile content of style element
1 parent b37e8a2 commit d656d11

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

src/AngularPublic.js

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function publishExternalAPI(angular){
7171
form: ngFormDirective,
7272
script: scriptTemplateLoader,
7373
select: selectDirective,
74+
style: styleDirective,
7475
option: optionDirective,
7576
ngBind: ngBindDirective,
7677
ngBindHtml: ngBindHtmlDirective,

src/directives.js

+6
Original file line numberDiff line numberDiff line change
@@ -969,3 +969,9 @@ var ngTranscludeDirective = valueFn({
969969
});
970970
}]
971971
});
972+
973+
974+
var styleDirective = valueFn({
975+
restrict: 'E',
976+
terminal: true
977+
});

test/directivesSpec.js

+24
Original file line numberDiff line numberDiff line change
@@ -557,4 +557,28 @@ describe("directive", function() {
557557
expect(element.hasClass('bar')).toBe(true);
558558
}));
559559
});
560+
561+
562+
describe('style', function() {
563+
564+
it('should not compile style element', inject(function($compile, $rootScope) {
565+
element = jqLite('<style type="text/css">should {{notBound}}</style>');
566+
$compile(element)($rootScope);
567+
$rootScope.$digest();
568+
569+
// read innerHTML and trim to pass on IE8
570+
expect(trim(element[0].innerHTML)).toBe('should {{notBound}}');
571+
}));
572+
573+
574+
it('should compile content of element with style attr', inject(function($compile, $rootScope) {
575+
element = jqLite('<div style="some">{{bind}}</div>');
576+
$compile(element)($rootScope);
577+
$rootScope.$apply(function() {
578+
$rootScope.bind = 'value';
579+
});
580+
581+
expect(element.text()).toBe('value');
582+
}));
583+
});
560584
});

0 commit comments

Comments
 (0)