mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
fix(nav): fixes empty stack condition
This commit is contained in:
@ -335,15 +335,6 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
|
||||
_postViewInit(enteringView: ViewController, leavingView: ViewController, ti: TransitionInstruction, resolve: TransitionResolveFn) {
|
||||
assert(leavingView || enteringView, 'Both leavingView and enteringView are null');
|
||||
|
||||
if (!enteringView && !this._isPortal) {
|
||||
console.warn(`You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.`,
|
||||
this, this.getNativeElement());
|
||||
|
||||
ti.reject && ti.reject('navigation stack needs at least one root page');
|
||||
return false;
|
||||
}
|
||||
|
||||
const opts = ti.opts || {};
|
||||
const insertViews = ti.insertViews;
|
||||
const removeStart = ti.removeStart;
|
||||
@ -366,6 +357,16 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
opts.direction = opts.direction || DIRECTION_BACK;
|
||||
}
|
||||
|
||||
const finalBalance = this._views.length + (insertViews ? insertViews.length : 0) - (destroyQueue ? destroyQueue.length : 0);
|
||||
assert(finalBalance >= 0, 'final balance can not be negative');
|
||||
if (finalBalance === 0 && !this._isPortal) {
|
||||
console.warn(`You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.`,
|
||||
this, this.getNativeElement());
|
||||
|
||||
ti.reject && ti.reject('navigation stack needs at least one root page');
|
||||
return false;
|
||||
}
|
||||
|
||||
// there are views to insert
|
||||
if (insertViews) {
|
||||
// manually set the new view's id if an id was passed in the options
|
||||
|
Reference in New Issue
Block a user