Skip to content

Commit f791a40

Browse files
joshcomleyMartoYankov
authored andcommitted
feat(css): add attribute scoped css without global refresh (#7907)
1 parent 5c9a217 commit f791a40

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

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

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

198-
export function addCss(cssText: string): void {
198+
export function addCss(cssText: string, attributeScoped?: boolean): void {
199199
notify(<CssChangedEventData>{ eventName: "cssChanged", object: androidApp, cssText: cssText });
200-
const rootView = getRootView();
201-
if (rootView) {
202-
rootView._onCssStateChange();
200+
if (!attributeScoped) {
201+
const rootView = getRootView();
202+
if (rootView) {
203+
rootView._onCssStateChange();
204+
}
203205
}
204206
}
205207

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ export function loadAppCss();
181181
/**
182182
* Adds new values to the application styles.
183183
* @param cssText - A valid styles which will be added to the current application styles.
184+
* @param attributeScoped - Whether the styles are attribute scoped. Adding attribute scoped styles will not perform a full application styling refresh.
184185
*/
185-
export function addCss(cssText: string): void;
186+
export function addCss(cssText: string, attributeScoped?: boolean): void;
186187

187188
/**
188189
* 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
@@ -419,11 +419,13 @@ export function run(entry?: string | NavigationEntry) {
419419
_start(entry);
420420
}
421421

422-
export function addCss(cssText: string): void {
422+
export function addCss(cssText: string, attributeScoped?: boolean): void {
423423
notify(<CssChangedEventData>{ eventName: "cssChanged", object: <any>iosApp, cssText: cssText });
424-
const rootView = getRootView();
425-
if (rootView) {
426-
rootView._onCssStateChange();
424+
if (!attributeScoped) {
425+
const rootView = getRootView();
426+
if (rootView) {
427+
rootView._onCssStateChange();
428+
}
427429
}
428430
}
429431

0 commit comments

Comments
 (0)