@@ -317,40 +317,37 @@ export class OverlayRef implements PortalOutlet {
317
317
detachBackdrop ( ) : void {
318
318
let backdropToDetach = this . _backdropElement ;
319
319
320
- if ( backdropToDetach ) {
321
- let finishDetach = ( ) => {
322
- // It may not be attached to anything in certain cases (e.g. unit tests).
323
- if ( backdropToDetach && backdropToDetach . parentNode ) {
324
- backdropToDetach . parentNode . removeChild ( backdropToDetach ) ;
325
- }
326
-
327
- // It is possible that a new portal has been attached to this overlay since we started
328
- // removing the backdrop. If that is the case, only clear the backdrop reference if it
329
- // is still the same instance that we started to remove.
330
- if ( this . _backdropElement == backdropToDetach ) {
331
- this . _backdropElement = null ;
332
- }
333
- } ;
334
-
335
- backdropToDetach . classList . remove ( 'cdk-overlay-backdrop-showing' ) ;
336
-
337
- if ( this . _config . backdropClass ) {
338
- backdropToDetach . classList . remove ( this . _config . backdropClass ) ;
320
+ if ( ! backdropToDetach ) {
321
+ return ;
322
+ }
323
+
324
+ let finishDetach = ( ) => {
325
+ // It may not be attached to anything in certain cases (e.g. unit tests).
326
+ if ( backdropToDetach && backdropToDetach . parentNode ) {
327
+ backdropToDetach . parentNode . removeChild ( backdropToDetach ) ;
339
328
}
340
329
341
- backdropToDetach . addEventListener ( 'transitionend' , finishDetach ) ;
330
+ // It is possible that a new portal has been attached to this overlay since we started
331
+ // removing the backdrop. If that is the case, only clear the backdrop reference if it
332
+ // is still the same instance that we started to remove.
333
+ if ( this . _backdropElement == backdropToDetach ) {
334
+ this . _backdropElement = null ;
335
+ }
336
+ } ;
342
337
343
- // If the backdrop doesn't have a transition, the `transitionend` event won't fire.
344
- // In this case we make it unclickable and we try to remove it after a delay.
345
- backdropToDetach . style . pointerEvents = 'none' ;
338
+ backdropToDetach . classList . remove ( 'cdk-overlay-backdrop-showing' ) ;
339
+ backdropToDetach . addEventListener ( 'transitionend' , finishDetach ) ;
346
340
347
- // Run this outside the Angular zone because there's nothing that Angular cares about.
348
- // If it were to run inside the Angular zone, every test that used Overlay would have to be
349
- // either async or fakeAsync.
350
- this . _ngZone . runOutsideAngular ( ( ) => {
351
- setTimeout ( finishDetach , 500 ) ;
352
- } ) ;
353
- }
341
+ // If the backdrop doesn't have a transition, the `transitionend` event won't fire.
342
+ // In this case we make it unclickable and we try to remove it after a delay.
343
+ backdropToDetach . style . pointerEvents = 'none' ;
344
+
345
+ // Run this outside the Angular zone because there's nothing that Angular cares about.
346
+ // If it were to run inside the Angular zone, every test that used Overlay would have to be
347
+ // either async or fakeAsync.
348
+ this . _ngZone . runOutsideAngular ( ( ) => {
349
+ setTimeout ( finishDetach , 500 ) ;
350
+ } ) ;
354
351
}
355
352
}
356
353
0 commit comments