mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00
test(view-controller): adds isOverlay asserts
This commit is contained in:
@ -4,7 +4,7 @@ import { Title, DOCUMENT } from '@angular/platform-browser';
|
||||
import { IonicApp } from './app-root';
|
||||
import * as Constants from './app-constants';
|
||||
import { ClickBlock } from './click-block';
|
||||
import { runInDev } from '../../util/util';
|
||||
import { runInDev, assert } from '../../util/util';
|
||||
import { Config } from '../../config/config';
|
||||
import { isNav, NavOptions, DIRECTION_FORWARD, DIRECTION_BACK } from '../../navigation/nav-util';
|
||||
import { MenuController } from './menu-controller';
|
||||
@ -226,6 +226,8 @@ export class App {
|
||||
* @hidden
|
||||
*/
|
||||
present(enteringView: ViewController, opts: NavOptions, appPortal?: number): Promise<any> {
|
||||
assert(enteringView.isOverlay, 'presented view controller needs to be an overlay');
|
||||
|
||||
const portal = this._appRoot._getPortal(appPortal);
|
||||
|
||||
// Set Nav must be set here in order to dimiss() work synchnously.
|
||||
|
@ -9,6 +9,7 @@ import { Keyboard } from '../../platform/keyboard';
|
||||
import { NavControllerBase } from '../../navigation/nav-controller-base';
|
||||
import { Platform } from '../../platform/platform';
|
||||
import { TransitionController } from '../../transitions/transition-controller';
|
||||
import { ViewController } from '../../navigation/view-controller';
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
@ -40,8 +41,10 @@ export class OverlayPortal extends NavControllerBase {
|
||||
|
||||
// on every page change make sure the portal has
|
||||
// dismissed any views that should be auto dismissed on page change
|
||||
app.viewDidLeave.subscribe((ev: any) => {
|
||||
!ev.isOverlay && this.dismissPageChangeViews();
|
||||
app.viewDidLeave.subscribe((view: ViewController) => {
|
||||
if (!view.isOverlay) {
|
||||
this.dismissPageChangeViews();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1117,7 +1117,7 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
dismissPageChangeViews() {
|
||||
for (let view of this._views) {
|
||||
if (view.data && view.data.dismissOnPageChange) {
|
||||
view.dismiss().catch(null);
|
||||
view.dismiss().catch(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user