Skip to content

Commit

Permalink
perf(theme): improve the creation of styles
Browse files Browse the repository at this point in the history
  • Loading branch information
alyleui committed Oct 29, 2018
1 parent a83986b commit 909a93f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/lib/src/theme/theme2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ const CLASSES_MAP: {
} = {};
const STYLE_KEYS_MAP = {};
let nextClassId = 0;
function fn() {
return CLASSES_MAP;
}

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -348,14 +345,16 @@ function styleToString(key: string, ob: Object, currentKey: string, parentKey?:
let subContent = '';
let keyAndValue = '';
let newKey;
if (parentKey && currentKey.indexOf('&') !== -1) {
newKey = currentKey.replace(/&/g, parentKey);
if (parentKey) {
if (currentKey.indexOf('&') !== -1) {
newKey = currentKey.replace(/&/g, parentKey);
} else if (currentKey.indexOf('@media') === 0) {
newKey = `${currentKey}`;
} else {
newKey = `${parentKey} ${currentKey}`;
}
} else if (key === '@global') {
newKey = key;
} else if (parentKey && currentKey.indexOf('@media') === 0) {
newKey = `${currentKey}`;
} else if (parentKey) {
newKey = `${parentKey} ${currentKey}`;
} else {
newKey = `.${currentKey}`;
}
Expand Down

0 comments on commit 909a93f

Please sign in to comment.