@@ -20,17 +20,27 @@ import {RippleConfig, RippleRenderer, RippleTarget, setLines} from '@angular/mat
2020import { Subscription } from 'rxjs' ;
2121import { 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 ( )
24- export class MatListBase {
32+ /** @docs -private */
33+ export abstract class MatListBase {
2534 // @HostBinding is used in the class as it is expected to be extended. Since @Component decorator
2635 // metadata is not inherited by child classes, instead the host binding data is defined in a way
2736 // that can be inherited.
2837 // tslint:disable-next-line:no-host-decorator-in-concrete
2938 @HostBinding ( 'class.mdc-list--non-interactive' )
30- _isNonInteractive : boolean ;
39+ _isNonInteractive : boolean = false ;
3140}
3241
3342@Directive ( )
43+ /** @docs -private */
3444export abstract class MatListItemBase implements AfterContentInit , OnDestroy , RippleTarget {
3545 lines : QueryList < ElementRef < Element > > ;
3646
@@ -67,8 +77,9 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri
6777 this . _subscriptions . add ( this . lines . changes . pipe ( startWith ( this . lines ) )
6878 . subscribe ( ( lines : QueryList < ElementRef < Element > > ) => {
6979 lines . forEach ( ( line : ElementRef < Element > , index : number ) => {
70- line . nativeElement . classList . toggle ( 'mdc-list-item__primary-text' , index === 0 ) ;
71- 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 ) ;
7283 } ) ;
7384 setLines ( lines , this . _element , 'mat-mdc' ) ;
7485 } ) ) ;
0 commit comments