feat(css): add attribute scoped css without global refresh (#7907) (#7947)

This commit is contained in:
Vladimir Amiorkov
2019-10-14 11:25:49 +03:00
committed by Manol Donev
parent b8b9a3d607
commit b377eb6ddb
3 changed files with 14 additions and 9 deletions

View File

@@ -177,11 +177,13 @@ export function run(entry?: NavigationEntry | string) {
_start(entry);
}
export function addCss(cssText: string): void {
export function addCss(cssText: string, attributeScoped?: boolean): void {
notify(<CssChangedEventData>{ eventName: "cssChanged", object: androidApp, cssText: cssText });
const rootView = getRootView();
if (rootView) {
rootView._onCssStateChange();
if (!attributeScoped) {
const rootView = getRootView();
if (rootView) {
rootView._onCssStateChange();
}
}
}

View File

@@ -171,8 +171,9 @@ export function loadAppCss();
/**
* Adds new values to the application styles.
* @param cssText - A valid styles which will be added to the current application styles.
* @param attributeScoped - Whether the styles are attribute scoped. Adding attribute scoped styles will not perform a full application styling refresh.
*/
export function addCss(cssText: string): void;
export function addCss(cssText: string, attributeScoped?: boolean): void;
/**
* This event is raised when application css is changed.

View File

@@ -370,11 +370,13 @@ export function run(entry?: string | NavigationEntry) {
_start(entry);
}
export function addCss(cssText: string): void {
export function addCss(cssText: string, attributeScoped?: boolean): void {
notify(<CssChangedEventData>{ eventName: "cssChanged", object: <any>iosApp, cssText: cssText });
const rootView = getRootView();
if (rootView) {
rootView._onCssStateChange();
if (!attributeScoped) {
const rootView = getRootView();
if (rootView) {
rootView._onCssStateChange();
}
}
}