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

Method _getAllRenderRows

src/cdk/table/table.ts:1048–1086  ·  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

1046 * so that the differ equates their references.
1047 */
1048 private _getAllRenderRows(): RenderRow<T>[] {
1049 // Note: the `_data` is typed as an array, but some internal apps end up passing diffrent types.
1050 if (!Array.isArray(this._data) || !this._renderedRange) {
1051 return [];
1052 }
1053
1054 const renderRows: RenderRow<T>[] = [];
1055 const end = Math.min(this._data.length, this._renderedRange.end);
1056
1057 // Store the cache and create a new one. Any re-used RenderRow objects will be moved into the
1058 // new cache while unused ones can be picked up by garbage collection.
1059 const prevCachedRenderRows = this._cachedRenderRowsMap;
1060 this._cachedRenderRowsMap = new Map();
1061
1062 // For each data object, get the list of rows that should be rendered, represented by the
1063 // respective `RenderRow` object which is the pair of `data` and `CdkRowDef`.
1064 for (let i = this._renderedRange.start; i < end; i++) {
1065 const data = this._data[i];
1066 const renderRowsForData = this._getRenderRowsForData(data, i, prevCachedRenderRows.get(data));
1067
1068 if (!this._cachedRenderRowsMap.has(data)) {
1069 this._cachedRenderRowsMap.set(data, new WeakMap());
1070 }
1071
1072 for (let j = 0; j < renderRowsForData.length; j++) {
1073 let renderRow = renderRowsForData[j];
1074
1075 const cache = this._cachedRenderRowsMap.get(renderRow.data)!;
1076 if (cache.has(renderRow.rowDef)) {
1077 cache.get(renderRow.rowDef)!.push(renderRow);
1078 } else {
1079 cache.set(renderRow.rowDef, [renderRow]);
1080 }
1081 renderRows.push(renderRow);
1082 }
1083 }
1084
1085 return renderRows;
1086 }
1087
1088 /**
1089 * 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