File tree Expand file tree Collapse file tree 2 files changed +12
-16
lines changed
tools/public_api_guard/cdk Expand file tree Collapse file tree 2 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
1414 ChangeDetectionStrategy ,
1515 ChangeDetectorRef ,
1616 Component ,
17+ DestroyRef ,
1718 ElementRef ,
1819 inject ,
1920 Inject ,
@@ -201,6 +202,17 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
201202 this . elementRef . nativeElement . classList . add ( 'cdk-virtual-scrollable' ) ;
202203 this . scrollable = this ;
203204 }
205+
206+ this . _injector . get ( DestroyRef ) . onDestroy ( ( ) => {
207+ this . _isDestroyed = true ;
208+ this . detach ( ) ;
209+ this . _scrollStrategy . detach ( ) ;
210+
211+ // Complete all subjects
212+ this . _renderedRangeSubject . complete ( ) ;
213+ this . _detachedSubject . complete ( ) ;
214+ this . _viewportChanges . unsubscribe ( ) ;
215+ } ) ;
204216 }
205217
206218 override ngOnInit ( ) {
@@ -242,20 +254,6 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
242254 ) ;
243255 }
244256
245- override ngOnDestroy ( ) {
246- this . detach ( ) ;
247- this . _scrollStrategy . detach ( ) ;
248-
249- // Complete all subjects
250- this . _renderedRangeSubject . complete ( ) ;
251- this . _detachedSubject . complete ( ) ;
252- this . _viewportChanges . unsubscribe ( ) ;
253-
254- this . _isDestroyed = true ;
255-
256- super . ngOnDestroy ( ) ;
257- }
258-
259257 /** Attaches a `CdkVirtualScrollRepeater` to this viewport. */
260258 attach ( forOf : CdkVirtualScrollRepeater < any > ) {
261259 if ( this . _forOf && ( typeof ngDevMode === 'undefined' || ngDevMode ) ) {
Original file line number Diff line number Diff line change @@ -197,8 +197,6 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
197197 // (undocumented)
198198 static ngAcceptInputType_appendOnly: unknown ;
199199 // (undocumented)
200- ngOnDestroy(): void ;
201- // (undocumented)
202200 ngOnInit(): void ;
203201 get orientation(): " horizontal" | " vertical" ;
204202 set orientation(orientation : ' horizontal' | ' vertical' );
You can’t perform that action at this time.
0 commit comments