MCPcopy Index your code
hub / github.com/angular/components / _calculateParents

Method _calculateParents

src/cdk/tree/tree.ts:1126–1148  ·  view source on GitHub ↗

Traverse the flattened node data and compute parents, levels, and group data.

(flattenedNodes: readonly T[])

Source from the content-addressed store, hash-verified

1124
1125 /** Traverse the flattened node data and compute parents, levels, and group data. */
1126 private _calculateParents(flattenedNodes: readonly T[]): void {
1127 const levelAccessor = this._getLevelAccessor();
1128 if (!levelAccessor) {
1129 return;
1130 }
1131
1132 // clear previously generated data so we don't keep end up retaining data overtime causing
1133 // memory leaks.
1134 this._clearPreviousCache();
1135
1136 for (let index = 0; index < flattenedNodes.length; index++) {
1137 const dataNode = flattenedNodes[index];
1138 const key = this._getExpansionKey(dataNode);
1139 this._levels.set(key, levelAccessor(dataNode));
1140 const parent = this._findParentForNode(dataNode, index, flattenedNodes);
1141 this._parents.set(key, parent);
1142 const parentKey = parent ? this._getExpansionKey(parent) : null;
1143
1144 const group = this._ariaSets.get(parentKey) ?? [];
1145 group.splice(index, 0, dataNode);
1146 this._ariaSets.set(parentKey, group);
1147 }
1148 }
1149
1150 /** Invokes a callback with all node expansion keys. */
1151 private _forEachExpansionKey(callback: (keys: K[]) => void) {

Callers 1

_computeRenderingDataMethod · 0.95

Calls 6

_getLevelAccessorMethod · 0.95
_clearPreviousCacheMethod · 0.95
_getExpansionKeyMethod · 0.95
_findParentForNodeMethod · 0.95
setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected