From 55260d208ad5a8e8199c1090b62940918069b868 Mon Sep 17 00:00:00 2001 From: Adam Rensel Date: Fri, 7 Feb 2014 14:49:09 -0500 Subject: [PATCH 1/2] Rewrite ngTransclude to use the new transclude link function, this fixes a memory leak when a directive using ng-transclude is compiled --- src/ng/directive/ngTransclude.js | 37 ++++++++++++++------------------ 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/ng/directive/ngTransclude.js b/src/ng/directive/ngTransclude.js index 295e47a9922c..3cf6a56e74b2 100644 --- a/src/ng/directive/ngTransclude.js +++ b/src/ng/directive/ngTransclude.js @@ -55,26 +55,21 @@ * */ -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); + }); + } } -}); +}; From 24a5e076a4c7243bbe710f76429bd74a25be1fdb Mon Sep 17 00:00:00 2001 From: Adam Rensel Date: Fri, 7 Feb 2014 15:52:49 -0500 Subject: [PATCH 2/2] Forgot a semicolon --- src/ng/directive/ngTransclude.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/directive/ngTransclude.js b/src/ng/directive/ngTransclude.js index 3cf6a56e74b2..7e52985cf810 100644 --- a/src/ng/directive/ngTransclude.js +++ b/src/ng/directive/ngTransclude.js @@ -71,5 +71,5 @@ var ngTranscludeDirective = function() { element.append(clone); }); } - } + }; };