Skip to content

Commit 02d955d

Browse files
committed
perf(list): reduce css selector size
Reduces the minified size of the list CSS from 31kb to 13kb by simplifying some of the selectors. We may be able to bring it down even further, however these changes are a bit safer in comparison.
1 parent e09ec34 commit 02d955d

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

src/lib/list/_list-theme.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$background: map-get($theme, background);
99
$foreground: map-get($theme, foreground);
1010

11-
.mat-list, .mat-nav-list, .mat-selection-list {
11+
.mat-list-base {
1212
.mat-list-item {
1313
color: mat-color($foreground, text);
1414
}
@@ -46,7 +46,7 @@
4646
}
4747

4848
// Default list
49-
.mat-list, .mat-nav-list, .mat-selection-list {
49+
.mat-list-base {
5050
.mat-list-item {
5151
font-size: mat-font-size($config, subheading-2);
5252
@include mat-line-base(mat-font-size($config, body-1));
@@ -65,7 +65,7 @@
6565
}
6666

6767
// Dense list
68-
.mat-list[dense], .mat-nav-list[dense], .mat-selection-list[dense] {
68+
.mat-list-base[dense] {
6969
.mat-list-item {
7070
font-size: mat-font-size($config, caption);
7171
@include mat-line-base(mat-font-size($config, caption));

src/lib/list/list.scss

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ $mat-list-item-inset-divider-offset: 72px;
189189

190190
// This needs slightly more specificity, because it
191191
// can be overwritten by the typography styles.
192-
.mat-list &,
193-
.mat-nav-list &,
194-
.mat-selection-list & {
192+
.mat-list-base & {
195193
margin: 0;
196194
}
197195
}
@@ -206,7 +204,7 @@ $mat-list-item-inset-divider-offset: 72px;
206204
}
207205
}
208206

209-
.mat-list, .mat-nav-list, .mat-selection-list {
207+
.mat-list-base {
210208
padding-top: $mat-list-top-padding;
211209
display: block;
212210
-webkit-tap-highlight-color: transparent;
@@ -229,9 +227,7 @@ $mat-list-item-inset-divider-offset: 72px;
229227
}
230228

231229

232-
.mat-list[dense],
233-
.mat-nav-list[dense],
234-
.mat-selection-list[dense] {
230+
.mat-list-base[dense] {
235231
padding-top: $mat-dense-top-padding;
236232
display: block;
237233

src/lib/list/list.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const _MatListItemMixinBase = mixinDisableRipple(MatListItemBase);
3636
exportAs: 'matNavList',
3737
host: {
3838
'role': 'navigation',
39-
'class': 'mat-nav-list'
39+
'class': 'mat-nav-list mat-list-base'
4040
},
4141
templateUrl: 'list.html',
4242
styleUrls: ['list.css'],
@@ -51,7 +51,9 @@ export class MatNavList extends _MatListMixinBase implements CanDisableRipple {}
5151
selector: 'mat-list',
5252
exportAs: 'matList',
5353
templateUrl: 'list.html',
54-
host: {'class': 'mat-list'},
54+
host: {
55+
'class': 'mat-list mat-list-base'
56+
},
5557
styleUrls: ['list.css'],
5658
inputs: ['disableRipple'],
5759
encapsulation: ViewEncapsulation.None,

src/lib/list/selection-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export class MatListOption extends _MatListOptionMixinBase
263263
host: {
264264
'role': 'listbox',
265265
'[tabIndex]': 'tabIndex',
266-
'class': 'mat-selection-list',
266+
'class': 'mat-selection-list mat-list-base',
267267
'(focus)': 'focus()',
268268
'(blur)': '_onTouched()',
269269
'(keydown)': '_keydown($event)',

0 commit comments

Comments
 (0)