File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -1010,6 +1010,10 @@ export class CdkTree<T, K = T>
1010
1010
return observableOf ( [ ...nodes ] ) ;
1011
1011
}
1012
1012
1013
+ // clear previously generated data so we don't keep end up retaining data overtime causing
1014
+ // memory leaks.
1015
+ this . _clearPreviousCache ( ) ;
1016
+
1013
1017
return observableOf ( ...nodes ) . pipe (
1014
1018
concatMap ( node => {
1015
1019
const parentKey = this . _getExpansionKey ( node ) ;
@@ -1125,8 +1129,9 @@ export class CdkTree<T, K = T>
1125
1129
return ;
1126
1130
}
1127
1131
1128
- this . _parents . clear ( ) ;
1129
- this . _ariaSets . clear ( ) ;
1132
+ // clear previously generated data so we don't keep end up retaining data overtime causing
1133
+ // memory leaks.
1134
+ this . _clearPreviousCache ( ) ;
1130
1135
1131
1136
for ( let index = 0 ; index < flattenedNodes . length ; index ++ ) {
1132
1137
const dataNode = flattenedNodes [ index ] ;
@@ -1163,6 +1168,13 @@ export class CdkTree<T, K = T>
1163
1168
callback ( toToggle ) ;
1164
1169
}
1165
1170
}
1171
+
1172
+ /** Clears the maps we use to store parents, level & aria-sets in. */
1173
+ private _clearPreviousCache ( ) {
1174
+ this . _parents . clear ( ) ;
1175
+ this . _levels . clear ( ) ;
1176
+ this . _ariaSets . clear ( ) ;
1177
+ }
1166
1178
}
1167
1179
1168
1180
/**
You can’t perform that action at this time.
0 commit comments