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

Commit 2ba4583

Browse files
committed
fix($compile): safely create transclude comment nodes
Closes #1740
1 parent 98489a1 commit 2ba4583

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ng/compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ function $CompileProvider($provide) {
575575
if (directiveValue == 'element') {
576576
$template = jqLite(compileNode);
577577
$compileNode = templateAttrs.$$element =
578-
jqLite('<!-- ' + directiveName + ': ' + templateAttrs[directiveName] + ' -->');
578+
jqLite(document.createComment(' ' + directiveName + ': ' + templateAttrs[directiveName] + ' '));
579579
compileNode = $compileNode[0];
580580
replaceWith($rootElement, jqLite($template[0]), compileNode);
581581
childTranscludeFn = compile($template, transcludeFn, terminalPriority);

test/ng/compileSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -2222,5 +2222,15 @@ describe('$compile', function() {
22222222
expect(nodeName_(comment)).toBe('#comment');
22232223
});
22242224
});
2225+
2226+
2227+
it('should safely create transclude comment node and not break with "-->"',
2228+
inject(function($rootScope) {
2229+
// see: https://github.com/angular/angular.js/issues/1740
2230+
element = $compile('<ul><li ng-repeat="item in [\'-->\', \'x\']">{{item}}|</li></ul>')($rootScope);
2231+
$rootScope.$digest();
2232+
2233+
expect(element.text()).toBe('-->|x|');
2234+
}));
22252235
});
22262236
});

0 commit comments

Comments
 (0)