@@ -95,12 +95,12 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges {
9595 private _overlayRef : OverlayRef ;
9696 private _templatePortal : TemplatePortal < any > ;
9797 private _hasBackdrop = false ;
98- private _backdropSubscription : Subscription | null ;
99- private _positionSubscription : Subscription ;
98+ private _backdropSubscription = Subscription . EMPTY ;
99+ private _positionSubscription = Subscription . EMPTY ;
100100 private _offsetX : number = 0 ;
101101 private _offsetY : number = 0 ;
102102 private _position : ConnectedPositionStrategy ;
103- private _escapeListener : Function ;
103+ private _escapeListener = ( ) => { } ;
104104
105105 /** Origin for the connected overlay. */
106106 @Input ( 'cdkConnectedOverlayOrigin' ) origin : OverlayOrigin ;
@@ -360,14 +360,8 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges {
360360 this . detach . emit ( ) ;
361361 }
362362
363- if ( this . _backdropSubscription ) {
364- this . _backdropSubscription . unsubscribe ( ) ;
365- this . _backdropSubscription = null ;
366- }
367-
368- if ( this . _escapeListener ) {
369- this . _escapeListener ( ) ;
370- }
363+ this . _backdropSubscription . unsubscribe ( ) ;
364+ this . _escapeListener ( ) ;
371365 }
372366
373367 /** Destroys the overlay created by this directive. */
@@ -376,17 +370,9 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges {
376370 this . _overlayRef . dispose ( ) ;
377371 }
378372
379- if ( this . _backdropSubscription ) {
380- this . _backdropSubscription . unsubscribe ( ) ;
381- }
382-
383- if ( this . _positionSubscription ) {
384- this . _positionSubscription . unsubscribe ( ) ;
385- }
386-
387- if ( this . _escapeListener ) {
388- this . _escapeListener ( ) ;
389- }
373+ this . _backdropSubscription . unsubscribe ( ) ;
374+ this . _positionSubscription . unsubscribe ( ) ;
375+ this . _escapeListener ( ) ;
390376 }
391377
392378 /** Sets the event listener that closes the overlay when pressing Escape. */
0 commit comments