diff options
| author | Igor Minar | 2013-01-09 22:07:33 -0800 |
|---|---|---|
| committer | Igor Minar | 2013-01-14 21:59:23 -0800 |
| commit | 2ba458387d19543b45c3bfdbe8db719d2c0f1f15 (patch) | |
| tree | 52810842afaf39a2dc85a4b3db2ee3f07cdd5734 | |
| parent | 98489a1d0cf289fc2261a02539b96d265cef8f09 (diff) | |
| download | angular.js-2ba458387d19543b45c3bfdbe8db719d2c0f1f15.tar.bz2 | |
fix($compile): safely create transclude comment nodes
Closes #1740
| -rw-r--r-- | src/ng/compile.js | 2 | ||||
| -rw-r--r-- | test/ng/compileSpec.js | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/ng/compile.js b/src/ng/compile.js index 9ed7f107..08c161f7 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -575,7 +575,7 @@ function $CompileProvider($provide) { if (directiveValue == 'element') { $template = jqLite(compileNode); $compileNode = templateAttrs.$$element = - jqLite('<!-- ' + directiveName + ': ' + templateAttrs[directiveName] + ' -->'); + jqLite(document.createComment(' ' + directiveName + ': ' + templateAttrs[directiveName] + ' ')); compileNode = $compileNode[0]; replaceWith($rootElement, jqLite($template[0]), compileNode); childTranscludeFn = compile($template, transcludeFn, terminalPriority); diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 75af0181..3a0e0289 100644 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -2222,5 +2222,15 @@ describe('$compile', function() { expect(nodeName_(comment)).toBe('#comment'); }); }); + + + it('should safely create transclude comment node and not break with "-->"', + inject(function($rootScope) { + // see: https://github.com/angular/angular.js/issues/1740 + element = $compile('<ul><li ng-repeat="item in [\'-->\', \'x\']">{{item}}|</li></ul>')($rootScope); + $rootScope.$digest(); + + expect(element.text()).toBe('-->|x|'); + })); }); }); |
