mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Fix Page to be styleScope if frame is not
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
8
tns-core-modules/ui/core/view/view.d.ts
vendored
8
tns-core-modules/ui/core/view/view.d.ts
vendored
@ -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
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user