Skip to content

Commit e31e011

Browse files
crisbetoandrewseguin
authored andcommitted
perf(list): reduce css selector size (#12571)
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 dc0b51a commit e31e011

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
@@ -197,9 +197,7 @@ $mat-list-item-inset-divider-offset: 72px;
197197

198198
// This needs slightly more specificity, because it
199199
// can be overwritten by the typography styles.
200-
.mat-list &,
201-
.mat-nav-list &,
202-
.mat-selection-list & {
200+
.mat-list-base & {
203201
margin: 0;
204202
}
205203
}
@@ -214,7 +212,7 @@ $mat-list-item-inset-divider-offset: 72px;
214212
}
215213
}
216214

217-
.mat-list, .mat-nav-list, .mat-selection-list {
215+
.mat-list-base {
218216
padding-top: $mat-list-top-padding;
219217
display: block;
220218
-webkit-tap-highlight-color: transparent;
@@ -237,9 +235,7 @@ $mat-list-item-inset-divider-offset: 72px;
237235
}
238236

239237

240-
.mat-list[dense],
241-
.mat-nav-list[dense],
242-
.mat-selection-list[dense] {
238+
.mat-list-base[dense] {
243239
padding-top: $mat-dense-top-padding;
244240
display: block;
245241

src/lib/list/list.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const _MatListItemMixinBase: CanDisableRippleCtor & typeof MatListItemBas
4444
exportAs: 'matNavList',
4545
host: {
4646
'role': 'navigation',
47-
'class': 'mat-nav-list'
47+
'class': 'mat-nav-list mat-list-base'
4848
},
4949
templateUrl: 'list.html',
5050
styleUrls: ['list.css'],
@@ -59,7 +59,9 @@ export class MatNavList extends _MatListMixinBase implements CanDisableRipple {}
5959
selector: 'mat-list, mat-action-list',
6060
exportAs: 'matList',
6161
templateUrl: 'list.html',
62-
host: {'class': 'mat-list'},
62+
host: {
63+
'class': 'mat-list mat-list-base'
64+
},
6365
styleUrls: ['list.css'],
6466
inputs: ['disableRipple'],
6567
encapsulation: ViewEncapsulation.None,

src/lib/list/selection-list.ts

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

0 commit comments

Comments
 (0)