Apply changes to the DOM.
(changes: IterableChanges<T>)
| 323 | |
| 324 | /** Apply changes to the DOM. */ |
| 325 | private _applyChanges(changes: IterableChanges<T>) { |
| 326 | this._viewRepeater.applyChanges( |
| 327 | changes, |
| 328 | this._viewContainerRef, |
| 329 | ( |
| 330 | record: IterableChangeRecord<T>, |
| 331 | _adjustedPreviousIndex: number | null, |
| 332 | currentIndex: number | null, |
| 333 | ) => this._getEmbeddedViewArgs(record, currentIndex!), |
| 334 | record => record.item, |
| 335 | ); |
| 336 | |
| 337 | // Update $implicit for any items that had an identity change. |
| 338 | changes.forEachIdentityChange((record: IterableChangeRecord<T>) => { |
| 339 | const view = this._viewContainerRef.get(record.currentIndex!) as EmbeddedViewRef< |
| 340 | CdkVirtualForOfContext<T> |
| 341 | >; |
| 342 | view.context.$implicit = record.item; |
| 343 | }); |
| 344 | |
| 345 | // Update the context variables on all items. |
| 346 | const count = this._data.length; |
| 347 | let i = this._viewContainerRef.length; |
| 348 | while (i--) { |
| 349 | const view = this._viewContainerRef.get(i) as EmbeddedViewRef<CdkVirtualForOfContext<T>>; |
| 350 | view.context.index = this._renderedRange.start + i; |
| 351 | view.context.count = count; |
| 352 | this._updateComputedContextProperties(view.context); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | /** Update the computed properties on the `CdkVirtualForOfContext`. */ |
| 357 | private _updateComputedContextProperties(context: CdkVirtualForOfContext<any>) { |
no test coverage detected