diff --git a/src/ng/compile.js b/src/ng/compile.js index 5026283ef516..29d66da577f9 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -581,7 +581,7 @@ function $CompileProvider($provide) { if (directiveValue == 'element') { $template = jqLite(compileNode); $compileNode = templateAttrs.$$element = - jqLite(''); + 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 5b644af9f75c..927a4ef77781 100644 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -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('')($rootScope); + $rootScope.$digest(); + + expect(element.text()).toBe('-->|x|'); + })); }); });