From ed66591db6488f419ccdbb9556c61b71a4407632 Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Mon, 1 May 2017 02:19:07 +0200 Subject: [PATCH] test(view-controller): adds isOverlay asserts --- src/components/app/app.ts | 4 +++- src/components/app/overlay-portal.ts | 7 +++++-- src/navigation/nav-controller-base.ts | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/app/app.ts b/src/components/app/app.ts index 883f1cb43b..aa76a86375 100644 --- a/src/components/app/app.ts +++ b/src/components/app/app.ts @@ -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 { + 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. diff --git a/src/components/app/overlay-portal.ts b/src/components/app/overlay-portal.ts index 0bc79493a8..78b213efc3 100644 --- a/src/components/app/overlay-portal.ts +++ b/src/components/app/overlay-portal.ts @@ -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(); + } }); } diff --git a/src/navigation/nav-controller-base.ts b/src/navigation/nav-controller-base.ts index 99f8c209c0..03c1f94a27 100644 --- a/src/navigation/nav-controller-base.ts +++ b/src/navigation/nav-controller-base.ts @@ -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(() => {}); } } }