Traverse the flattened node data and compute parents, levels, and group data.
(flattenedNodes: readonly T[])
| 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) { |
no test coverage detected