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

Commit

Permalink
fix($compile): safely create transclude comment nodes
Browse files Browse the repository at this point in the history
Closes #1740
  • Loading branch information
IgorMinar committed Jan 15, 2013
1 parent c0cb9f8 commit 74dd2f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,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);
Expand Down
10 changes: 10 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2241,5 +2241,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|');
}));
});
});

0 comments on commit 74dd2f7

Please sign in to comment.