mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 19:40:56 +08:00
fix($compile): fix nested isolated transclude directives
Closes #1809 Closes #7499
This commit is contained in:
committed by
Caitlin Potter
parent
30279d7b9b
commit
bb9310974b
@@ -947,7 +947,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
// or
|
||||
// - there is no parentBoundTranscludeFn already and a transcludeFn was passed in
|
||||
if ( nodeLinkFn.transcludeOnThisElement || (!parentBoundTranscludeFn && transcludeFn) ) {
|
||||
childBoundTranscludeFn = createBoundTranscludeFn(scope, nodeLinkFn.transclude || transcludeFn);
|
||||
childBoundTranscludeFn = createBoundTranscludeFn(scope, nodeLinkFn.transclude || transcludeFn, parentBoundTranscludeFn);
|
||||
} else {
|
||||
childBoundTranscludeFn = parentBoundTranscludeFn;
|
||||
}
|
||||
@@ -961,8 +961,13 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
}
|
||||
}
|
||||
|
||||
function createBoundTranscludeFn(scope, transcludeFn) {
|
||||
return function boundTranscludeFn(transcludedScope, cloneFn, controllers) {
|
||||
function createBoundTranscludeFn(scope, transcludeFn, previousBoundTranscludeFn) {
|
||||
|
||||
// If there is a previous boundTransclude function and it has a transclusionScope then
|
||||
// use this instead of the current scope
|
||||
scope = previousBoundTranscludeFn && previousBoundTranscludeFn.transclusionScope || scope;
|
||||
|
||||
var boundTranscludeFn = function(transcludedScope, cloneFn, controllers) {
|
||||
var scopeCreated = false;
|
||||
|
||||
if (!transcludedScope) {
|
||||
@@ -977,6 +982,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
}
|
||||
return clone;
|
||||
};
|
||||
|
||||
// Store the transclusionScope for nested transclusions
|
||||
boundTranscludeFn.transclusionScope = scope;
|
||||
|
||||
return boundTranscludeFn;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1749,7 +1759,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
safeAddClass(jqLite(linkNode), oldClasses);
|
||||
}
|
||||
if (afterTemplateNodeLinkFn.transclude) {
|
||||
childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude);
|
||||
childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude, boundTranscludeFn);
|
||||
} else {
|
||||
childBoundTranscludeFn = boundTranscludeFn;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user