@@ -2205,6 +2205,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2205
2205
// This is the function that is injected as `$transclude`.
2206
2206
// Note: all arguments are optional!
2207
2207
function controllersBoundTransclude ( scope , cloneAttachFn , futureParentElement , slotName ) {
2208
+ if ( ! boundTranscludeFn ) {
2209
+ throw $compileMinErr ( 'multitransclude' , 'This element has already been transcluded.' ) ;
2210
+ }
2211
+
2208
2212
var transcludeControllers ;
2209
2213
// No scope passed in:
2210
2214
if ( ! isScope ( scope ) ) {
@@ -2221,16 +2225,21 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2221
2225
futureParentElement = hasElementTranscludeDirective ? $element . parent ( ) : $element ;
2222
2226
}
2223
2227
if ( slotName ) {
2224
- var slotTranscludeFn = boundTranscludeFn . $$slots [ slotName ] ;
2225
- if ( ! slotTranscludeFn ) {
2228
+ boundTranscludeFn = boundTranscludeFn . $$slots [ slotName ] ;
2229
+ if ( ! boundTranscludeFn ) {
2226
2230
throw $compileMinErr ( 'noslot' ,
2227
2231
'No parent directive that requires a transclusion with slot name "{0}". ' +
2228
2232
'Element: {1}' ,
2229
2233
slotName , startingTag ( $element ) ) ;
2230
2234
}
2231
- return slotTranscludeFn ( scope , cloneAttachFn , transcludeControllers , futureParentElement , scopeToChild ) ;
2232
2235
}
2233
- return boundTranscludeFn ( scope , cloneAttachFn , transcludeControllers , futureParentElement , scopeToChild ) ;
2236
+
2237
+ var res = boundTranscludeFn ( scope , cloneAttachFn , transcludeControllers , futureParentElement , scopeToChild ) ;
2238
+ //Clear references not required if this transcluded the original nodes
2239
+ if ( ! cloneAttachFn ) {
2240
+ boundTranscludeFn = scopeToChild = elementControllers = $element = null ;
2241
+ }
2242
+ return res ;
2234
2243
}
2235
2244
}
2236
2245
}
0 commit comments