Skip to content

Commit 22c21b7

Browse files
authored
fix(core): page frame reference not unset on native view disposal (#10417)
1 parent c78ea79 commit 22c21b7

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

packages/core/ui/frame/frame-common.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ export class FrameBase extends CustomLayoutView {
201201
public _removeEntry(removed: BackstackEntry): void {
202202
const page = removed.resolvedPage;
203203
const frame = page.frame;
204-
page._frame = null;
205204
if (frame) {
206205
frame._removeView(page);
207206
} else {
@@ -250,7 +249,6 @@ export class FrameBase extends CustomLayoutView {
250249
this._resolvedPage = newPage;
251250

252251
this._addView(newPage);
253-
newPage._frame = this;
254252
}
255253

256254
this._currentEntry = entry;

packages/core/ui/page/index.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ export declare class Page extends PageBase {
143143
* @private
144144
*/
145145
hasActionBar: boolean;
146-
/**
147-
* @private
148-
*/
149-
_frame: Frame;
150146

151147
/**
152148
* A method called before navigating to the page.

packages/core/ui/page/index.ios.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ class UIViewControllerImpl extends UIViewController {
134134
frame._resolvedPage = owner;
135135

136136
if (!owner.parent) {
137-
owner._frame = frame;
138137
if (!frame._styleScope) {
139138
// Make sure page will have styleScope even if frame don't.
140139
owner._updateStyleScope();
@@ -427,10 +426,6 @@ export class Page extends PageBase {
427426
return this._ios;
428427
}
429428

430-
get frame(): Frame {
431-
return this._frame;
432-
}
433-
434429
public layoutNativeView(left: number, top: number, right: number, bottom: number): void {
435430
//
436431
}
@@ -440,7 +435,7 @@ export class Page extends PageBase {
440435
}
441436

442437
public _shouldDelayLayout(): boolean {
443-
return this._frame && this._frame._animationInProgress;
438+
return this.frame && this.frame._animationInProgress;
444439
}
445440

446441
public onLoaded(): void {
@@ -469,7 +464,7 @@ export class Page extends PageBase {
469464

470465
public _updateStatusBarStyle(value?: string) {
471466
const frame = this.frame;
472-
if (this.frame && value) {
467+
if (frame && value) {
473468
const navigationController: UINavigationController = frame.ios.controller;
474469
const navigationBar = navigationController.navigationBar;
475470

packages/core/ui/page/page-common.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ export class PageBase extends ContentView {
2727
private _navigationContext: any;
2828
private _actionBar: ActionBar;
2929

30-
public _frame: Frame;
31-
3230
public actionBarHidden: boolean;
3331
public enableSwipeBackNavigation: boolean;
3432
public backgroundSpanUnderStatusBar: boolean;
@@ -81,6 +79,15 @@ export class PageBase extends ContentView {
8179
return this;
8280
}
8381

82+
public _parentChanged(oldParent: View): void {
83+
const newParent = this.parent;
84+
if (newParent && !isFrame(newParent)) {
85+
throw new Error(`Page can only be nested inside Frame. New parent: ${newParent}`);
86+
}
87+
88+
super._parentChanged(oldParent);
89+
}
90+
8491
public _addChildFromBuilder(name: string, value: any) {
8592
if (value instanceof ActionBar) {
8693
this.actionBar = value;
@@ -94,9 +101,7 @@ export class PageBase extends ContentView {
94101
}
95102

96103
get frame(): Frame {
97-
const parent = this.parent;
98-
99-
return isFrame(parent) ? (parent as Frame) : undefined;
104+
return <Frame>this.parent;
100105
}
101106

102107
private createNavigatedData(eventName: string, isBackNavigation: boolean): NavigatedData {

0 commit comments

Comments
 (0)