From 4c1c50fd9bfafaa89cdc66dfde818a3f8f4b0c6b Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Tue, 28 Feb 2012 11:51:14 -0800 Subject: [PATCH] fix(directive.script): Do not compile content of script tags --- src/widgets.js | 1 + test/widgetsSpec.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/widgets.js b/src/widgets.js index 84982dc6c3d..d515d94d211 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -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; diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index fcd6fc0457b..6f0e3731b3b 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -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('
'); + // jQuery is too smart and removes + doc[0].innerHTML = '' + + ''; + + $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); + })); }); });