Skip to content

Commit 9843b59

Browse files
committed
address comments
1 parent 4e60ff3 commit 9843b59

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/material-experimental/mdc-list/list-base.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ import {RippleConfig, RippleRenderer, RippleTarget, setLines} from '@angular/mat
2020
import {Subscription} from 'rxjs';
2121
import {startWith} from 'rxjs/operators';
2222

23+
function toggleClass(el: Element, className: string, on: boolean) {
24+
if (on) {
25+
el.classList.add(className);
26+
} else {
27+
el.classList.remove(className);
28+
}
29+
}
30+
2331
@Directive()
2432
/** @docs-private */
2533
export abstract class MatListBase {
@@ -69,9 +77,9 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri
6977
this._subscriptions.add(this.lines.changes.pipe(startWith(this.lines))
7078
.subscribe((lines: QueryList<ElementRef<Element>>) => {
7179
lines.forEach((line: ElementRef<Element>, index: number) => {
72-
line.nativeElement.classList
73-
.toggle('mdc-list-item__primary-text', index === 0 && lines.length > 1);
74-
line.nativeElement.classList.toggle('mdc-list-item__secondary-text', index !== 0);
80+
toggleClass(line.nativeElement,
81+
'mdc-list-item__primary-text', index === 0 && lines.length > 1);
82+
toggleClass(line.nativeElement, 'mdc-list-item__secondary-text', index !== 0);
7583
});
7684
setLines(lines, this._element, 'mat-mdc');
7785
}));

src/material-experimental/mdc-list/list-item.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
If lines were not explicitly given, assume the remaining content is the text, otherwise assume it
1010
is an action that belongs in the "meta" section.
1111
-->
12-
<span [class.mdc-list-item__text]="!lines.length" [class.mdc-list-item__meta]="!!lines.length">
12+
<span [class.mdc-list-item__text]="!lines.length" [class.mdc-list-item__meta]="lines.length">
1313
<ng-content></ng-content>
1414
</span>
1515

0 commit comments

Comments
 (0)