Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions tns-core-modules/application/application.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion tns-core-modules/application/application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions tns-core-modules/application/application.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down