Fix Page to be styleScope if frame is not

This commit is contained in:
Hristo Hristov
2018-01-12 10:23:54 +02:00
parent 8a428b011a
commit ef86addd6d
3 changed files with 18 additions and 5 deletions

View File

@ -80,18 +80,18 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
return scope && scope.css; return scope && scope.css;
} }
set css(value: string) { set css(value: string) {
this.updateStyleScope(undefined, undefined, value); this._updateStyleScope(undefined, undefined, value);
} }
public addCss(cssString: string): void { public addCss(cssString: string): void {
this.updateStyleScope(undefined, cssString); this._updateStyleScope(undefined, cssString);
} }
public addCssFile(cssFileName: string) { 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; let scope = this._styleScope;
if (!scope) { if (!scope) {
scope = new StyleScope(); scope = new StyleScope();
@ -117,7 +117,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
_setupAsRootView(context: any): void { _setupAsRootView(context: any): void {
super._setupAsRootView(context); super._setupAsRootView(context);
if (!this._styleScope) { if (!this._styleScope) {
this.updateStyleScope(); this._updateStyleScope();
} }
} }

View File

@ -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. * @param cssFileName - A valid file name (from the application root) which contains a valid css.
*/ */
addCssFile(cssFileName: string): void; 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 //@endprivate
/** /**

View File

@ -657,6 +657,11 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
page._setupUI(context); page._setupUI(context);
} }
} else { } else {
if (!this.frame._styleScope) {
// Make sure page will have styleScope even if parents don't.
page._updateStyleScope();
}
this.frame._addView(page); this.frame._addView(page);
} }