diff --git a/packages/core/ui/frame/frame-common.ts b/packages/core/ui/frame/frame-common.ts index a7baacec3..495126486 100644 --- a/packages/core/ui/frame/frame-common.ts +++ b/packages/core/ui/frame/frame-common.ts @@ -201,7 +201,6 @@ export class FrameBase extends CustomLayoutView { public _removeEntry(removed: BackstackEntry): void { const page = removed.resolvedPage; const frame = page.frame; - page._frame = null; if (frame) { frame._removeView(page); } else { @@ -250,7 +249,6 @@ export class FrameBase extends CustomLayoutView { this._resolvedPage = newPage; this._addView(newPage); - newPage._frame = this; } this._currentEntry = entry; diff --git a/packages/core/ui/page/index.d.ts b/packages/core/ui/page/index.d.ts index 86ab38b78..024cebd8b 100644 --- a/packages/core/ui/page/index.d.ts +++ b/packages/core/ui/page/index.d.ts @@ -143,10 +143,6 @@ export declare class Page extends PageBase { * @private */ hasActionBar: boolean; - /** - * @private - */ - _frame: Frame; /** * A method called before navigating to the page. diff --git a/packages/core/ui/page/index.ios.ts b/packages/core/ui/page/index.ios.ts index 421c63459..48063ee9a 100644 --- a/packages/core/ui/page/index.ios.ts +++ b/packages/core/ui/page/index.ios.ts @@ -134,7 +134,6 @@ class UIViewControllerImpl extends UIViewController { frame._resolvedPage = owner; if (!owner.parent) { - owner._frame = frame; if (!frame._styleScope) { // Make sure page will have styleScope even if frame don't. owner._updateStyleScope(); @@ -427,10 +426,6 @@ export class Page extends PageBase { return this._ios; } - get frame(): Frame { - return this._frame; - } - public layoutNativeView(left: number, top: number, right: number, bottom: number): void { // } @@ -440,7 +435,7 @@ export class Page extends PageBase { } public _shouldDelayLayout(): boolean { - return this._frame && this._frame._animationInProgress; + return this.frame && this.frame._animationInProgress; } public onLoaded(): void { @@ -469,7 +464,7 @@ export class Page extends PageBase { public _updateStatusBarStyle(value?: string) { const frame = this.frame; - if (this.frame && value) { + if (frame && value) { const navigationController: UINavigationController = frame.ios.controller; const navigationBar = navigationController.navigationBar; diff --git a/packages/core/ui/page/page-common.ts b/packages/core/ui/page/page-common.ts index 195ec71b2..709b3afe8 100644 --- a/packages/core/ui/page/page-common.ts +++ b/packages/core/ui/page/page-common.ts @@ -27,8 +27,6 @@ export class PageBase extends ContentView { private _navigationContext: any; private _actionBar: ActionBar; - public _frame: Frame; - public actionBarHidden: boolean; public enableSwipeBackNavigation: boolean; public backgroundSpanUnderStatusBar: boolean; @@ -81,6 +79,15 @@ export class PageBase extends ContentView { return this; } + public _parentChanged(oldParent: View): void { + const newParent = this.parent; + if (newParent && !isFrame(newParent)) { + throw new Error(`Page can only be nested inside Frame. New parent: ${newParent}`); + } + + super._parentChanged(oldParent); + } + public _addChildFromBuilder(name: string, value: any) { if (value instanceof ActionBar) { this.actionBar = value; @@ -94,9 +101,7 @@ export class PageBase extends ContentView { } get frame(): Frame { - const parent = this.parent; - - return isFrame(parent) ? (parent as Frame) : undefined; + return this.parent; } private createNavigatedData(eventName: string, isBackNavigation: boolean): NavigatedData {