Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 08793a6

Browse files
Daniel Tabuencacaitp
Daniel Tabuenca
authored andcommitted
refactor(ngTransclude): use transclusion function passed in to link
Since we now pass in the transclusion function directly to the link function, we no longer need the old scheme whereby we saved the transclude function injected into the controller for later use in during linking. Additionally, this change may aid in correcting a memory leak of detached DOM nodes (see #6181 for details). This commit removes the controller and simplifies ngTransclude. Closes #5375 Closes #6181
1 parent ef4bf8c commit 08793a6

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/ng/directive/ngTransclude.js

+7-14
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,16 @@
5656
*
5757
*/
5858
var ngTranscludeDirective = ngDirective({
59-
controller: ['$element', '$transclude', function($element, $transclude) {
59+
link: function($scope, $element, $attrs, controller, $transclude) {
6060
if (!$transclude) {
6161
throw minErr('ngTransclude')('orphan',
62-
'Illegal use of ngTransclude directive in the template! ' +
63-
'No parent directive that requires a transclusion found. ' +
64-
'Element: {0}',
65-
startingTag($element));
62+
'Illegal use of ngTransclude directive in the template! ' +
63+
'No parent directive that requires a transclusion found. ' +
64+
'Element: {0}',
65+
startingTag($element));
6666
}
67-
68-
// remember the transclusion fn but call it during linking so that we don't process transclusion before directives on
69-
// the parent element even when the transclusion replaces the current element. (we can't use priority here because
70-
// that applies only to compile fns and not controllers
71-
this.$transclude = $transclude;
72-
}],
73-
74-
link: function($scope, $element, $attrs, controller) {
75-
controller.$transclude(function(clone) {
67+
68+
$transclude(function(clone) {
7669
$element.empty();
7770
$element.append(clone);
7871
});

0 commit comments

Comments
 (0)