FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Page and Frame isLoaded undefined checks by vakrilov · Pull Request #6255 · NativeScript/NativeScript · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (4) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 2 additions & 2 deletions tns-core-modules/ui/core/view-base/view-base.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -595,13 +595,13 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
}

public loadView(view: ViewBase): void {
if (!view.isLoaded) {
if (view && !view.isLoaded) {
view.callLoaded();
}
}

public unloadView(view: ViewBase): void {
if (view.isLoaded) {
if (view && view.isLoaded) {
view.callUnloaded();
}
}
Expand Down
4 changes: 2 additions & 2 deletions tns-core-modules/ui/core/view/view.android.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function initializeDialogFragment() {
}

const owner = this.owner;
if (!owner.isLoaded) {
if (owner && !owner.isLoaded) {
owner.callLoaded();
}

Expand All @@ -194,7 +194,7 @@ function initializeDialogFragment() {
}

const owner = this.owner;
if (owner.isLoaded) {
if (owner && owner.isLoaded) {
owner.callUnloaded();
}
}
Expand Down
21 changes: 18 additions & 3 deletions tns-core-modules/ui/frame/frame.android.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Page } from "../page";
import * as application from "../../application";
import {
FrameBase, stack, goBack, View, Observable,
traceEnabled, traceWrite, traceCategories
traceEnabled, traceWrite, traceCategories, traceError
} from "./frame-common";

import {
Expand Down Expand Up @@ -720,8 +720,23 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
}

const entry = this.entry;
if (!entry) {
traceError(`${fragment}.onCreateView: entry is null or undefined`);
return null;
}

const page = entry.resolvedPage;
if (!page) {
traceError(`${fragment}.onCreateView: entry has no resolvedPage`);
return null;
}

const frame = this.frame;
if (!frame) {
traceError(`${fragment}.onCreateView: this.frame is null or undefined`);
return null;
}

if (page.parent === frame) {
// If we are navigating to a page that was destroyed
// reinitialize its UI.
Expand All @@ -730,12 +745,12 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
page._setupUI(context);
}
} else {
if (!this.frame._styleScope) {
if (!frame._styleScope) {
// Make sure page will have styleScope even if parents don't.
page._updateStyleScope();
}

this.frame._addView(page);
frame._addView(page);
}

if (frame.isLoaded && !page.isLoaded) {
Expand Down
2 changes: 1 addition & 1 deletion tns-core-modules/ui/styling/style-scope.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export class CssState {
* As a result, at some point in time, the selectors matched have to be requerried from the style scope and applied to the view.
*/
public onChange(): void {
if (this.view.isLoaded) {
if (this.view && this.view.isLoaded) {
this.unsubscribeFromDynamicUpdates();
this.updateMatch();
this.subscribeForDynamicUpdates();
Expand Down

Back | FazBrowse Home | New Git URL