From bc1301485a65d762351a5c34041b726c580e2315 Mon Sep 17 00:00:00 2001 From: Josh Comley Date: Sat, 5 Oct 2019 16:05:30 +0100 Subject: [PATCH 1/2] Support for adding scoped CSS for bug fix: https://github.com/NativeScript/theme/issues/179 --- tns-core-modules/application/application.android.ts | 10 ++++++---- tns-core-modules/application/application.ios.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tns-core-modules/application/application.android.ts b/tns-core-modules/application/application.android.ts index 25e04594bd..a4e22b0ecf 100644 --- a/tns-core-modules/application/application.android.ts +++ b/tns-core-modules/application/application.android.ts @@ -177,11 +177,13 @@ export function run(entry?: NavigationEntry | string) { _start(entry); } -export function addCss(cssText: string): void { +export function addCss(cssText: string, scoped?: boolean): void { notify({ eventName: "cssChanged", object: androidApp, cssText: cssText }); - const rootView = getRootView(); - if (rootView) { - rootView._onCssStateChange(); + if(!scoped) { + const rootView = getRootView(); + if (rootView) { + rootView._onCssStateChange(); + } } } diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts index 33220468af..37bd5b3706 100644 --- a/tns-core-modules/application/application.ios.ts +++ b/tns-core-modules/application/application.ios.ts @@ -371,11 +371,13 @@ export function run(entry?: string | NavigationEntry) { _start(entry); } -export function addCss(cssText: string): void { +export function addCss(cssText: string, scoped?: boolean): void { notify({ eventName: "cssChanged", object: iosApp, cssText: cssText }); - const rootView = getRootView(); - if (rootView) { - rootView._onCssStateChange(); + if (!scoped) { + const rootView = getRootView(); + if (rootView) { + rootView._onCssStateChange(); + } } } From 570c3776d1d15768f6104aafeaedc81e310ca3d0 Mon Sep 17 00:00:00 2001 From: Josh Comley Date: Tue, 8 Oct 2019 10:20:11 +0100 Subject: [PATCH 2/2] Implementing change requests --- tns-core-modules/application/application.android.ts | 4 ++-- tns-core-modules/application/application.d.ts | 3 ++- tns-core-modules/application/application.ios.ts | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tns-core-modules/application/application.android.ts b/tns-core-modules/application/application.android.ts index a4e22b0ecf..22c7f7c54a 100644 --- a/tns-core-modules/application/application.android.ts +++ b/tns-core-modules/application/application.android.ts @@ -177,9 +177,9 @@ export function run(entry?: NavigationEntry | string) { _start(entry); } -export function addCss(cssText: string, scoped?: boolean): void { +export function addCss(cssText: string, attributeScoped?: boolean): void { notify({ eventName: "cssChanged", object: androidApp, cssText: cssText }); - if(!scoped) { + if (!attributeScoped) { const rootView = getRootView(); if (rootView) { rootView._onCssStateChange(); diff --git a/tns-core-modules/application/application.d.ts b/tns-core-modules/application/application.d.ts index 48217c411b..c64f5102e0 100644 --- a/tns-core-modules/application/application.d.ts +++ b/tns-core-modules/application/application.d.ts @@ -171,8 +171,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. diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts index 37bd5b3706..2083cd9934 100644 --- a/tns-core-modules/application/application.ios.ts +++ b/tns-core-modules/application/application.ios.ts @@ -371,9 +371,9 @@ export function run(entry?: string | NavigationEntry) { _start(entry); } -export function addCss(cssText: string, scoped?: boolean): void { +export function addCss(cssText: string, attributeScoped?: boolean): void { notify({ eventName: "cssChanged", object: iosApp, cssText: cssText }); - if (!scoped) { + if (!attributeScoped) { const rootView = getRootView(); if (rootView) { rootView._onCssStateChange();