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

Commit

Permalink
fix(directive.script): Do not compile content of script tags
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Feb 28, 2012
1 parent d1558d7 commit 4c1c50f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ var ngPluralizeDirective = ['$locale', '$interpolate', function($locale, $interp

var scriptTemplateLoader = ['$templateCache', function($templateCache) {
return {
terminal: true,
compile: function(element, attr) {
if (attr.type == 'text/ng-template') {
var templateUrl = attr.id;
Expand Down
18 changes: 18 additions & 0 deletions test/widgetsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,5 +949,23 @@ describe('widget', function() {
expect($templateCache.get('/ignore')).toBeUndefined();
}
));


it('should not compile scripts', inject(function($compile, $templateCache, $rootScope) {
if (msie <=8) return; // see above

var doc = jqLite('<div></div>');
// jQuery is too smart and removes
doc[0].innerHTML = '<script type="text/javascript">some {{binding}}</script>' +
'<script type="text/ng-template" id="/some">other {{binding}}</script>';

$compile(doc)($rootScope);
$rootScope.$digest();

var scripts = doc.find('script');
expect(scripts.eq(0).text()).toBe('some {{binding}}');
expect(scripts.eq(1).text()).toBe('other {{binding}}');
dealoc(doc);
}));
});
});

0 comments on commit 4c1c50f

Please sign in to comment.