From ef86addd6d4fdefebd0495588c7cdd9b0706688b Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 12 Jan 2018 10:23:54 +0200 Subject: [PATCH] Fix Page to be styleScope if frame is not --- tns-core-modules/ui/core/view/view-common.ts | 10 +++++----- tns-core-modules/ui/core/view/view.d.ts | 8 ++++++++ tns-core-modules/ui/frame/frame.android.ts | 5 +++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tns-core-modules/ui/core/view/view-common.ts b/tns-core-modules/ui/core/view/view-common.ts index da66c2925..25bf1f9ea 100644 --- a/tns-core-modules/ui/core/view/view-common.ts +++ b/tns-core-modules/ui/core/view/view-common.ts @@ -80,18 +80,18 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { return scope && scope.css; } set css(value: string) { - this.updateStyleScope(undefined, undefined, value); + this._updateStyleScope(undefined, undefined, value); } public addCss(cssString: string): void { - this.updateStyleScope(undefined, cssString); + this._updateStyleScope(undefined, cssString); } public addCssFile(cssFileName: string) { - this.updateStyleScope(cssFileName); + this._updateStyleScope(cssFileName); } - private updateStyleScope(cssFileName?: string, cssString?: string, css?: string): void { + public _updateStyleScope(cssFileName?: string, cssString?: string, css?: string): void { let scope = this._styleScope; if (!scope) { scope = new StyleScope(); @@ -117,7 +117,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { _setupAsRootView(context: any): void { super._setupAsRootView(context); if (!this._styleScope) { - this.updateStyleScope(); + this._updateStyleScope(); } } diff --git a/tns-core-modules/ui/core/view/view.d.ts b/tns-core-modules/ui/core/view/view.d.ts index d96ff0b20..058a551c3 100644 --- a/tns-core-modules/ui/core/view/view.d.ts +++ b/tns-core-modules/ui/core/view/view.d.ts @@ -658,6 +658,14 @@ export abstract class View extends ViewBase { * @param cssFileName - A valid file name (from the application root) which contains a valid css. */ addCssFile(cssFileName: string): void; + + /** + * Updates styleScope or create new styleScope. + * @param cssFileName + * @param cssString + * @param css + */ + _updateStyleScope(cssFileName?: string, cssString?: string, css?: string): void; //@endprivate /** diff --git a/tns-core-modules/ui/frame/frame.android.ts b/tns-core-modules/ui/frame/frame.android.ts index ff4ab0f8e..63e40dc40 100644 --- a/tns-core-modules/ui/frame/frame.android.ts +++ b/tns-core-modules/ui/frame/frame.android.ts @@ -657,6 +657,11 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { page._setupUI(context); } } else { + if (!this.frame._styleScope) { + // Make sure page will have styleScope even if parents don't. + page._updateStyleScope(); + } + this.frame._addView(page); }