@@ -37,33 +37,33 @@ export const MAT_BUTTON_HOST = {
37
37
} ;
38
38
39
39
/** List of classes to add to buttons instances based on host attribute selector. */
40
- const HOST_SELECTOR_MDC_CLASS_PAIR : { selector : string ; mdcClasses : string [ ] } [ ] = [
40
+ const HOST_SELECTOR_MDC_CLASS_PAIR : { attribute : string ; mdcClasses : string [ ] } [ ] = [
41
41
{
42
- selector : 'mat-button' ,
42
+ attribute : 'mat-button' ,
43
43
mdcClasses : [ 'mdc-button' , 'mat-mdc-button' ] ,
44
44
} ,
45
45
{
46
- selector : 'mat-flat-button' ,
46
+ attribute : 'mat-flat-button' ,
47
47
mdcClasses : [ 'mdc-button' , 'mdc-button--unelevated' , 'mat-mdc-unelevated-button' ] ,
48
48
} ,
49
49
{
50
- selector : 'mat-raised-button' ,
50
+ attribute : 'mat-raised-button' ,
51
51
mdcClasses : [ 'mdc-button' , 'mdc-button--raised' , 'mat-mdc-raised-button' ] ,
52
52
} ,
53
53
{
54
- selector : 'mat-stroked-button' ,
54
+ attribute : 'mat-stroked-button' ,
55
55
mdcClasses : [ 'mdc-button' , 'mdc-button--outlined' , 'mat-mdc-outlined-button' ] ,
56
56
} ,
57
57
{
58
- selector : 'mat-fab' ,
58
+ attribute : 'mat-fab' ,
59
59
mdcClasses : [ 'mdc-fab' , 'mat-mdc-fab' ] ,
60
60
} ,
61
61
{
62
- selector : 'mat-mini-fab' ,
62
+ attribute : 'mat-mini-fab' ,
63
63
mdcClasses : [ 'mdc-fab' , 'mdc-fab--mini' , 'mat-mdc-mini-fab' ] ,
64
64
} ,
65
65
{
66
- selector : 'mat-icon-button' ,
66
+ attribute : 'mat-icon-button' ,
67
67
mdcClasses : [ 'mdc-icon-button' , 'mat-mdc-icon-button' ] ,
68
68
} ,
69
69
] ;
@@ -128,15 +128,14 @@ export class MatButtonBase implements AfterViewInit, OnDestroy {
128
128
className : 'mat-mdc-button-ripple' ,
129
129
} ) ;
130
130
131
- const classList = ( _elementRef . nativeElement as HTMLElement ) . classList ;
131
+ const element = this . _elementRef . nativeElement ;
132
+ const classList = ( element as HTMLElement ) . classList ;
132
133
133
134
// For each of the variant selectors that is present in the button's host
134
135
// attributes, add the correct corresponding MDC classes.
135
- for ( const pair of HOST_SELECTOR_MDC_CLASS_PAIR ) {
136
- if ( this . _hasHostAttributes ( pair . selector ) ) {
137
- pair . mdcClasses . forEach ( ( className : string ) => {
138
- classList . add ( className ) ;
139
- } ) ;
136
+ for ( const { attribute, mdcClasses} of HOST_SELECTOR_MDC_CLASS_PAIR ) {
137
+ if ( element . hasAttribute ( attribute ) ) {
138
+ classList . add ( ...mdcClasses ) ;
140
139
}
141
140
}
142
141
}
@@ -158,11 +157,6 @@ export class MatButtonBase implements AfterViewInit, OnDestroy {
158
157
}
159
158
}
160
159
161
- /** Gets whether the button has one of the given attributes. */
162
- private _hasHostAttributes ( ...attributes : string [ ] ) {
163
- return attributes . some ( attribute => this . _elementRef . nativeElement . hasAttribute ( attribute ) ) ;
164
- }
165
-
166
160
private _updateRippleDisabled ( ) : void {
167
161
this . _rippleLoader ?. setDisabled (
168
162
this . _elementRef . nativeElement ,
0 commit comments