@@ -62,6 +62,7 @@ export class NavControllerBase extends Ion implements NavController {
62
62
_viewport : ViewContainerRef ;
63
63
_views : ViewController [ ] = [ ] ;
64
64
_zIndexOffset : number = 0 ;
65
+ _destroyed : boolean ;
65
66
66
67
viewDidLoad : EventEmitter < any > = new EventEmitter ( ) ;
67
68
viewWillEnter : EventEmitter < any > = new EventEmitter ( ) ;
@@ -102,6 +103,7 @@ export class NavControllerBase extends Ion implements NavController {
102
103
this . _sbEnabled = config . getBoolean ( 'swipeBackEnabled' ) ;
103
104
this . _children = [ ] ;
104
105
this . id = 'n' + ( ++ ctrlIds ) ;
106
+ this . _destroyed = false ;
105
107
}
106
108
107
109
push ( page : any , params ?: any , opts ?: NavOptions , done ?: ( ) => void ) : Promise < any > {
@@ -284,7 +286,7 @@ export class NavControllerBase extends Ion implements NavController {
284
286
if ( ti . done ) {
285
287
ti . done ( false , false , rejectReason ) ;
286
288
}
287
- if ( ti . reject ) {
289
+ if ( ti . reject && ! this . _destroyed ) {
288
290
ti . reject ( rejectReason ) ;
289
291
} else {
290
292
ti . resolve ( false ) ;
@@ -594,7 +596,6 @@ export class NavControllerBase extends Ion implements NavController {
594
596
}
595
597
596
598
_transition ( enteringView : ViewController , leavingView : ViewController , ti : TransitionInstruction ) : Promise < NavResult > {
597
-
598
599
if ( ! ti . requiresTransition ) {
599
600
// transition is not required, so we are already done!
600
601
// they're inserting/removing the views somewhere in the middle or
@@ -856,35 +857,38 @@ export class NavControllerBase extends Ion implements NavController {
856
857
_cleanup ( activeView : ViewController ) {
857
858
// ok, cleanup time!! Destroy all of the views that are
858
859
// INACTIVE and come after the active view
859
- const activeViewIndex = this . _views . indexOf ( activeView ) ;
860
- const views = this . _views ;
861
- let reorderZIndexes = false ;
862
- let view : ViewController ;
863
- let i : number ;
860
+ // only do this if the views exist, though
861
+ if ( ! this . _destroyed ) {
862
+ const activeViewIndex = this . _views . indexOf ( activeView ) ;
863
+ const views = this . _views ;
864
+ let reorderZIndexes = false ;
865
+ let view : ViewController ;
866
+ let i : number ;
864
867
865
- for ( i = views . length - 1 ; i >= 0 ; i -- ) {
866
- view = views [ i ] ;
867
- if ( i > activeViewIndex ) {
868
- // this view comes after the active view
869
- // let's unload it
870
- this . _willUnload ( view ) ;
871
- this . _destroyView ( view ) ;
872
-
873
- } else if ( i < activeViewIndex && ! this . _isPortal ) {
874
- // this view comes before the active view
875
- // and it is not a portal then ensure it is hidden
876
- view . _domShow ( false , this . _renderer ) ;
877
- }
878
- if ( view . _zIndex <= 0 ) {
879
- reorderZIndexes = true ;
868
+ for ( i = views . length - 1 ; i >= 0 ; i -- ) {
869
+ view = views [ i ] ;
870
+ if ( i > activeViewIndex ) {
871
+ // this view comes after the active view
872
+ // let's unload it
873
+ this . _willUnload ( view ) ;
874
+ this . _destroyView ( view ) ;
875
+
876
+ } else if ( i < activeViewIndex && ! this . _isPortal ) {
877
+ // this view comes before the active view
878
+ // and it is not a portal then ensure it is hidden
879
+ view . _domShow ( false , this . _renderer ) ;
880
+ }
881
+ if ( view . _zIndex <= 0 ) {
882
+ reorderZIndexes = true ;
883
+ }
880
884
}
881
- }
882
885
883
- if ( ! this . _isPortal && reorderZIndexes ) {
884
- for ( i = 0 ; i < views . length ; i ++ ) {
885
- view = views [ i ] ;
886
- // ******** DOM WRITE ****************
887
- view . _setZIndex ( view . _zIndex + INIT_ZINDEX + 1 , this . _renderer ) ;
886
+ if ( ! this . _isPortal && reorderZIndexes ) {
887
+ for ( i = 0 ; i < views . length ; i ++ ) {
888
+ view = views [ i ] ;
889
+ // ******** DOM WRITE ****************
890
+ view . _setZIndex ( view . _zIndex + INIT_ZINDEX + 1 , this . _renderer ) ;
891
+ }
888
892
}
889
893
}
890
894
}
@@ -1021,6 +1025,8 @@ export class NavControllerBase extends Ion implements NavController {
1021
1025
if ( this . parent && this . parent . unregisterChildNav ) {
1022
1026
this . parent . unregisterChildNav ( this ) ;
1023
1027
}
1028
+
1029
+ this . _destroyed = true ;
1024
1030
}
1025
1031
1026
1032
swipeBackStart ( ) {
0 commit comments