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

Commit 4c1c50f

Browse files
committed
fix(directive.script): Do not compile content of script tags
1 parent d1558d7 commit 4c1c50f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/widgets.js

+1
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ var ngPluralizeDirective = ['$locale', '$interpolate', function($locale, $interp
783783

784784
var scriptTemplateLoader = ['$templateCache', function($templateCache) {
785785
return {
786+
terminal: true,
786787
compile: function(element, attr) {
787788
if (attr.type == 'text/ng-template') {
788789
var templateUrl = attr.id;

test/widgetsSpec.js

+18
Original file line numberDiff line numberDiff line change
@@ -949,5 +949,23 @@ describe('widget', function() {
949949
expect($templateCache.get('/ignore')).toBeUndefined();
950950
}
951951
));
952+
953+
954+
it('should not compile scripts', inject(function($compile, $templateCache, $rootScope) {
955+
if (msie <=8) return; // see above
956+
957+
var doc = jqLite('<div></div>');
958+
// jQuery is too smart and removes
959+
doc[0].innerHTML = '<script type="text/javascript">some {{binding}}</script>' +
960+
'<script type="text/ng-template" id="/some">other {{binding}}</script>';
961+
962+
$compile(doc)($rootScope);
963+
$rootScope.$digest();
964+
965+
var scripts = doc.find('script');
966+
expect(scripts.eq(0).text()).toBe('some {{binding}}');
967+
expect(scripts.eq(1).text()).toBe('other {{binding}}');
968+
dealoc(doc);
969+
}));
952970
});
953971
});

0 commit comments

Comments
 (0)