forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix($compile): link async+replace element transclusion directives wit…
…h 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 angular#6006
- Loading branch information
Showing
2 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<ii; ++i) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
caitp
Author
Owner
|
||
if (directives[i].transclude === 'element') { | ||
replaceTransclude = true; | ||
break; | ||
} | ||
} | ||
} else { | ||
compileNode = beforeTemplateCompileNode; | ||
$compileNode.html(content); | ||
|
@@ -1712,12 +1718,18 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { | |
|
||
if (beforeTemplateLinkNode !== beforeTemplateCompileNode) { | ||
var oldClasses = beforeTemplateLinkNode.className; | ||
// it was cloned therefore we have to clone as well. | ||
linkNode = jqLiteClone(compileNode); | ||
|
||
if (!replaceTransclude) { | ||
// it was cloned therefore we have to clone as well. | ||
linkNode = jqLiteClone(compileNode); | ||
} | ||
|
||
replaceWith(linkRootElement, jqLite(beforeTemplateLinkNode), linkNode); | ||
|
||
// Copy in CSS classes from original node | ||
safeAddClass(jqLite(linkNode), oldClasses); | ||
if (isDefined(oldClasses)) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
// Copy in CSS classes from original node | ||
safeAddClass(jqLite(linkNode), oldClasses); | ||
} | ||
} | ||
if (afterTemplateNodeLinkFn.transclude) { | ||
childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this seems to duplicate what
previousCompileContext
is for. though I think that we'd need to erase hasElementTranscludeDirective frompreviousCompileContext
before using it again when the template returns. or maybe not? not sure right now.