mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
feat(css): add attribute scoped css without global refresh (#7907)
This commit is contained in:

committed by
Martin Yankov

parent
5c9a217bc5
commit
f791a403cd
@ -195,11 +195,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,8 +181,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.
|
||||
|
@ -419,11 +419,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user