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

ngTransclude memory leak fix #6181

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 17 additions & 22 deletions src/ng/directive/ngTransclude.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,21 @@
</doc:example>
*
*/
var ngTranscludeDirective = ngDirective({
controller: ['$element', '$transclude', function($element, $transclude) {
if (!$transclude) {
throw minErr('ngTransclude')('orphan',
'Illegal use of ngTransclude directive in the template! ' +
'No parent directive that requires a transclusion found. ' +
'Element: {0}',
startingTag($element));
}

// remember the transclusion fn but call it during linking so that we don't process transclusion before directives on
// the parent element even when the transclusion replaces the current element. (we can't use priority here because
// that applies only to compile fns and not controllers
this.$transclude = $transclude;
}],
var ngTranscludeDirective = function() {
return {
link: function(scope, element, attrs, ctrl, transclude){
if (!transclude) {
throw minErr('ngTransclude')('orphan',
'Illegal use of ngTransclude directive in the template! ' +
'No parent directive that requires a transclusion found. ' +
'Element: {0}',
startingTag(element));
}

link: function($scope, $element, $attrs, controller) {
controller.$transclude(function(clone) {
$element.empty();
$element.append(clone);
});
}
});
transclude(function(clone) {
element.empty();
element.append(clone);
});
}
};
};