MCPcopy Create free account
hub / github.com/angular/components / _getAllRenderRows

Method _getAllRenderRows

src/cdk/table/table.ts:1066–1104  ·  view source on GitHub ↗

* Get the list of RenderRow objects to render according to the current list of data and defined * row definitions. If the previous list already contained a particular pair, it should be reused * so that the differ equates their references.

()

Source from the content-addressed store, hash-verified

1064 * so that the differ equates their references.
1065 */
1066 private _getAllRenderRows(): RenderRow<T>[] {
1067 // Note: the `_data` is typed as an array, but some internal apps end up passing diffrent types.
1068 if (!Array.isArray(this._data) || !this._renderedRange) {
1069 return [];
1070 }
1071
1072 const renderRows: RenderRow<T>[] = [];
1073 const end = Math.min(this._data.length, this._renderedRange.end);
1074
1075 // Store the cache and create a new one. Any re-used RenderRow objects will be moved into the
1076 // new cache while unused ones can be picked up by garbage collection.
1077 const prevCachedRenderRows = this._cachedRenderRowsMap;
1078 this._cachedRenderRowsMap = new Map();
1079
1080 // For each data object, get the list of rows that should be rendered, represented by the
1081 // respective `RenderRow` object which is the pair of `data` and `CdkRowDef`.
1082 for (let i = this._renderedRange.start; i < end; i++) {
1083 const data = this._data[i];
1084 const renderRowsForData = this._getRenderRowsForData(data, i, prevCachedRenderRows.get(data));
1085
1086 if (!this._cachedRenderRowsMap.has(data)) {
1087 this._cachedRenderRowsMap.set(data, new WeakMap());
1088 }
1089
1090 for (let j = 0; j < renderRowsForData.length; j++) {
1091 let renderRow = renderRowsForData[j];
1092
1093 const cache = this._cachedRenderRowsMap.get(renderRow.data)!;
1094 if (cache.has(renderRow.rowDef)) {
1095 cache.get(renderRow.rowDef)!.push(renderRow);
1096 } else {
1097 cache.set(renderRow.rowDef, [renderRow]);
1098 }
1099 renderRows.push(renderRow);
1100 }
1101 }
1102
1103 return renderRows;
1104 }
1105
1106 /**
1107 * Gets a list of `RenderRow<T>` for the provided data object and any `CdkRowDef` objects that

Callers 1

renderRowsMethod · 0.95

Calls 5

_getRenderRowsForDataMethod · 0.95
setMethod · 0.80
getMethod · 0.65
pushMethod · 0.65
minMethod · 0.45

Tested by

no test coverage detected