mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix-next(css-classes): increase application CSS selector version at runtime (#7992)
This commit is contained in:
committed by
Manol Donev
parent
07abee748c
commit
bfea96fbc0
@@ -142,6 +142,14 @@ function removeCssClass(rootView: View, cssClass: string) {
|
||||
rootView.cssClasses.delete(cssClass);
|
||||
}
|
||||
|
||||
function increaseStyleScopeApplicationCssSelectorVersion(rootView: View) {
|
||||
const styleScope = rootView._styleScope || ((<any>rootView).currentPage && (<any>rootView).currentPage._styleScope);
|
||||
|
||||
if (styleScope) {
|
||||
styleScope._increaseApplicationCssSelectorVersion();
|
||||
}
|
||||
}
|
||||
|
||||
export function orientationChanged(rootView: View, newOrientation: "portrait" | "landscape" | "unknown"): void {
|
||||
if (!rootView) {
|
||||
return;
|
||||
@@ -151,6 +159,7 @@ export function orientationChanged(rootView: View, newOrientation: "portrait" |
|
||||
if (!rootView.cssClasses.has(newOrientationCssClass)) {
|
||||
ORIENTATION_CSS_CLASSES.forEach(cssClass => removeCssClass(rootView, cssClass));
|
||||
applyCssClass(rootView, newOrientationCssClass);
|
||||
increaseStyleScopeApplicationCssSelectorVersion(rootView);
|
||||
rootView._onCssStateChange();
|
||||
}
|
||||
}
|
||||
@@ -164,6 +173,7 @@ export function systemAppearanceChanged(rootView: View, newSystemAppearance: "da
|
||||
if (!rootView.cssClasses.has(newSystemAppearanceCssClass)) {
|
||||
SYSTEM_APPEARANCE_CSS_CLASSES.forEach(cssClass => removeCssClass(rootView, cssClass));
|
||||
applyCssClass(rootView, newSystemAppearanceCssClass);
|
||||
increaseStyleScopeApplicationCssSelectorVersion(rootView);
|
||||
rootView._onCssStateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,10 @@ export class StyleScope {
|
||||
public static createSelectorsFromImports(tree: SyntaxTree, keyframes: Object): RuleSet[];
|
||||
public ensureSelectors(): number;
|
||||
|
||||
/**
|
||||
* Increase the application CSS selector version.
|
||||
*/
|
||||
public _increaseApplicationCssSelectorVersion(): void;
|
||||
public isApplicationCssSelectorsLatestVersionApplied(): boolean;
|
||||
public isLocalCssSelectorsLatestVersionApplied(): boolean;
|
||||
|
||||
|
||||
@@ -760,6 +760,10 @@ export class StyleScope {
|
||||
return this._getSelectorsVersion();
|
||||
}
|
||||
|
||||
public _increaseApplicationCssSelectorVersion(): void {
|
||||
applicationCssSelectorVersion++;
|
||||
}
|
||||
|
||||
public isApplicationCssSelectorsLatestVersionApplied(): boolean {
|
||||
return this._applicationCssSelectorsAppliedVersion === applicationCssSelectorVersion;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user