@@ -20,6 +20,14 @@ import {RippleConfig, RippleRenderer, RippleTarget, setLines} from '@angular/mat
20
20
import { Subscription } from 'rxjs' ;
21
21
import { startWith } from 'rxjs/operators' ;
22
22
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
+
23
31
@Directive ( )
24
32
/** @docs -private */
25
33
export abstract class MatListBase {
@@ -69,9 +77,9 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri
69
77
this . _subscriptions . add ( this . lines . changes . pipe ( startWith ( this . lines ) )
70
78
. subscribe ( ( lines : QueryList < ElementRef < Element > > ) => {
71
79
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 ) ;
75
83
} ) ;
76
84
setLines ( lines , this . _element , 'mat-mdc' ) ;
77
85
} ) ) ;
0 commit comments