From daa40591b14b7575beb749fe12d9d4111db9634c Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 28 Jan 2014 11:34:01 -0500 Subject: [PATCH] fix($compile): link async+replace element transclusion directives with comment element Previously, element transclusion directives would not receive a comment node in their link functions when they were the root of an asynchronous replace template. This would cause duplicate elements to appear in an ng-if expression within ng-repeat. Closes #6006 --- src/ng/compile.js | 22 ++++++++++++++----- test/ng/compileSpec.js | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 36c23086b1ee..2916e21480a2 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1662,7 +1662,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { $http.get($sce.getTrustedResourceUrl(templateUrl), {cache: $templateCache}). success(function(content) { - var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn; + var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn, replaceTransclude; content = denormalizeTemplate(content); @@ -1685,6 +1685,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { } directives = templateDirectives.concat(directives); mergeTemplateAttributes(tAttrs, tempTemplateAttrs); + for (var i=0, ii=directives.length; i

Content

'); + element = $compile('
')($rootScope); + $rootScope.$digest(); + var child = element.children(); + + expect(log.toArray()).toEqual(["outer:#comment", "innerAgain:#comment", "inner:#comment"]); + expect(child.length).toBe(1); + expect(child.contents().length).toBe(2); + expect(lowercase(nodeName_(child.contents().eq(0)))).toBe('#comment'); + expect(lowercase(nodeName_(child.contents().eq(1)))).toBe('div'); + }); + }); }); it('should safely create transclude comment node and not break with "-->"',