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,12 +195,14 @@ 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";
|
||||||
|
@ -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.
|
||||||
|
@ -419,12 +419,14 @@ 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) {
|
||||||
|
Reference in New Issue
Block a user