@@ -335,15 +335,6 @@ export class NavControllerBase extends Ion implements NavController {
335
335
336
336
_postViewInit ( enteringView : ViewController , leavingView : ViewController , ti : TransitionInstruction , resolve : TransitionResolveFn ) {
337
337
assert ( leavingView || enteringView , 'Both leavingView and enteringView are null' ) ;
338
-
339
- if ( ! enteringView && ! this . _isPortal ) {
340
- console . warn ( `You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.` ,
341
- this , this . getNativeElement ( ) ) ;
342
-
343
- ti . reject && ti . reject ( 'navigation stack needs at least one root page' ) ;
344
- return false ;
345
- }
346
-
347
338
const opts = ti . opts || { } ;
348
339
const insertViews = ti . insertViews ;
349
340
const removeStart = ti . removeStart ;
@@ -366,6 +357,16 @@ export class NavControllerBase extends Ion implements NavController {
366
357
opts . direction = opts . direction || DIRECTION_BACK ;
367
358
}
368
359
360
+ const finalBalance = this . _views . length + ( insertViews ? insertViews . length : 0 ) - ( destroyQueue ? destroyQueue . length : 0 ) ;
361
+ assert ( finalBalance >= 0 , 'final balance can not be negative' ) ;
362
+ if ( finalBalance === 0 && ! this . _isPortal ) {
363
+ console . warn ( `You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.` ,
364
+ this , this . getNativeElement ( ) ) ;
365
+
366
+ ti . reject && ti . reject ( 'navigation stack needs at least one root page' ) ;
367
+ return false ;
368
+ }
369
+
369
370
// there are views to insert
370
371
if ( insertViews ) {
371
372
// manually set the new view's id if an id was passed in the options
0 commit comments