Skip to content

Commit b377eb6

Browse files
Vladimir Amiorkovmanoldonev
authored andcommitted
feat(css): add attribute scoped css without global refresh (#7907) (#7947)
1 parent b8b9a3d commit b377eb6

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

‎tns-core-modules/application/application.android.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,13 @@ export function run(entry?: NavigationEntry | string) {
177177
_start(entry);
178178
}
179179

180-
export function addCss(cssText: string): void {
180+
export function addCss(cssText: string, attributeScoped?: boolean): void {
181181
notify(<CssChangedEventData>{ eventName: "cssChanged", object: androidApp, cssText: cssText });
182-
const rootView = getRootView();
183-
if (rootView) {
184-
rootView._onCssStateChange();
182+
if (!attributeScoped) {
183+
const rootView = getRootView();
184+
if (rootView) {
185+
rootView._onCssStateChange();
186+
}
185187
}
186188
}
187189

‎tns-core-modules/application/application.d.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ export function loadAppCss();
171171
/**
172172
* Adds new values to the application styles.
173173
* @param cssText - A valid styles which will be added to the current application styles.
174+
* @param attributeScoped - Whether the styles are attribute scoped. Adding attribute scoped styles will not perform a full application styling refresh.
174175
*/
175-
export function addCss(cssText: string): void;
176+
export function addCss(cssText: string, attributeScoped?: boolean): void;
176177

177178
/**
178179
* This event is raised when application css is changed.

‎tns-core-modules/application/application.ios.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,13 @@ export function run(entry?: string | NavigationEntry) {
370370
_start(entry);
371371
}
372372

373-
export function addCss(cssText: string): void {
373+
export function addCss(cssText: string, attributeScoped?: boolean): void {
374374
notify(<CssChangedEventData>{ eventName: "cssChanged", object: <any>iosApp, cssText: cssText });
375-
const rootView = getRootView();
376-
if (rootView) {
377-
rootView._onCssStateChange();
375+
if (!attributeScoped) {
376+
const rootView = getRootView();
377+
if (rootView) {
378+
rootView._onCssStateChange();
379+
}
378380
}
379381
}
380382

0 commit comments

Comments
 (0)