fix-next(css-classes): increase application CSS selector version at runtime (#7992)

This commit is contained in:
Vasil Chimev
2019-10-22 13:54:02 +03:00
committed by Manol Donev
parent 07abee748c
commit bfea96fbc0
3 changed files with 18 additions and 0 deletions

View File

@@ -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();
}
}

View File

@@ -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;

View File

@@ -760,6 +760,10 @@ export class StyleScope {
return this._getSelectorsVersion();
}
public _increaseApplicationCssSelectorVersion(): void {
applicationCssSelectorVersion++;
}
public isApplicationCssSelectorsLatestVersionApplied(): boolean {
return this._applicationCssSelectorsAppliedVersion === applicationCssSelectorVersion;
}