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

This commit is contained in:
joshcomley
2019-10-08 13:35:39 +01:00
committed by Martin Yankov
parent 5c9a217bc5
commit f791a403cd
3 changed files with 14 additions and 9 deletions

View File

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

View File

@ -181,8 +181,9 @@ export function loadAppCss();
/** /**
* Adds new values to the application styles. * Adds new values to the application styles.
* @param cssText - A valid styles which will be added to the current 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. * This event is raised when application css is changed.

View File

@ -419,13 +419,15 @@ export function run(entry?: string | NavigationEntry) {
_start(entry); _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 }); notify(<CssChangedEventData>{ eventName: "cssChanged", object: <any>iosApp, cssText: cssText });
if (!attributeScoped) {
const rootView = getRootView(); const rootView = getRootView();
if (rootView) { if (rootView) {
rootView._onCssStateChange(); rootView._onCssStateChange();
} }
} }
}
export function _resetRootView(entry?: NavigationEntry | string) { export function _resetRootView(entry?: NavigationEntry | string) {
createRootFrame.value = false; createRootFrame.value = false;