mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
@@ -216,6 +216,10 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
}
|
||||
|
||||
_success(result: NavResult, ti: TransitionInstruction) {
|
||||
if (this._queue === null) {
|
||||
this._fireError('nav controller was destroyed', ti);
|
||||
return;
|
||||
}
|
||||
this._init = true;
|
||||
this._trnsId = null;
|
||||
|
||||
@@ -237,6 +241,10 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
}
|
||||
|
||||
_failed(rejectReason: any, ti: TransitionInstruction) {
|
||||
if (this._queue === null) {
|
||||
this._fireError('nav controller was destroyed', ti);
|
||||
return;
|
||||
}
|
||||
this._trnsId = null;
|
||||
this._queue.length = 0;
|
||||
|
||||
@@ -245,6 +253,10 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
this._swipeBackCheck();
|
||||
this._nextTrns();
|
||||
|
||||
this._fireError(rejectReason, ti);
|
||||
}
|
||||
|
||||
_fireError(rejectReason: any, ti: TransitionInstruction) {
|
||||
if (ti.done) {
|
||||
ti.done(false, false, rejectReason);
|
||||
}
|
||||
|
||||
@@ -1068,6 +1068,23 @@ describe('NavController', () => {
|
||||
|
||||
});
|
||||
|
||||
describe('destroy', () => {
|
||||
|
||||
it('should not crash when destroyed while transitioning', (done) => {
|
||||
let view1 = mockView(MockView1);
|
||||
nav.push(view1).then(() => {
|
||||
fail('it should not succeed');
|
||||
done();
|
||||
}).catch((err: any) => {
|
||||
expect(err).toEqual('nav controller was destroyed');
|
||||
done();
|
||||
});
|
||||
nav.destroy();
|
||||
}, 10000);
|
||||
|
||||
});
|
||||
|
||||
|
||||
let nav: NavControllerBase;
|
||||
let trnsDone: jasmine.Spy;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user