Skip to content

Commit ca8b0b2

Browse files
committed
perf(rootScope): Fix a memory leak
Closes angular#11169
1 parent 2d0eda1 commit ca8b0b2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ng/rootScope.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ function $RootScopeProvider() {
8383
this.$get = ['$injector', '$exceptionHandler', '$parse', '$browser',
8484
function($injector, $exceptionHandler, $parse, $browser) {
8585

86+
function destroyChildScope($event) {
87+
$event.currentScope.$$destroyed = true;
88+
}
89+
8690
/**
8791
* @ngdoc type
8892
* @name $rootScope.Scope
@@ -233,13 +237,9 @@ function $RootScopeProvider() {
233237
// prototypically. In all other cases, this property needs to be set
234238
// when the parent scope is destroyed.
235239
// The listener needs to be added after the parent is set
236-
if (isolate || parent != this) child.$on('$destroy', destroyChild);
240+
if (isolate || parent != this) child.$on('$destroy', destroyChildScope);
237241

238242
return child;
239-
240-
function destroyChild() {
241-
child.$$destroyed = true;
242-
}
243243
},
244244

245245
/**

0 commit comments

Comments
 (0)