@@ -41,6 +41,7 @@ import {
41
41
} from '@angular/material/core' ;
42
42
import { Subject } from 'rxjs' ;
43
43
import { take } from 'rxjs/operators' ;
44
+ import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
44
45
45
46
46
47
/** Represents an event fired on an individual `mat-chip`. */
@@ -108,6 +109,7 @@ export class MatChipTrailingIcon {}
108
109
'[class.mat-chip-with-avatar]' : 'avatar' ,
109
110
'[class.mat-chip-with-trailing-icon]' : 'trailingIcon || removeIcon' ,
110
111
'[class.mat-chip-disabled]' : 'disabled' ,
112
+ '[class._mat-animation-noopable]' : '_animationsDisabled' ,
111
113
'[attr.disabled]' : 'disabled || null' ,
112
114
'[attr.aria-disabled]' : 'disabled.toString()' ,
113
115
'[attr.aria-selected]' : 'ariaSelected' ,
@@ -142,6 +144,9 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes
142
144
/** Whether the chip has focus. */
143
145
_hasFocus : boolean = false ;
144
146
147
+ /** Whether animations for the chip are enabled. */
148
+ _animationsDisabled : boolean ;
149
+
145
150
/** Whether the chip list is selectable */
146
151
chipListSelectable : boolean = true ;
147
152
@@ -221,30 +226,34 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes
221
226
return this . selectable ? this . selected . toString ( ) : null ;
222
227
}
223
228
224
- constructor ( public _elementRef : ElementRef ,
229
+ constructor ( public _elementRef : ElementRef < HTMLElement > ,
225
230
private _ngZone : NgZone ,
226
231
platform : Platform ,
227
232
@Optional ( ) @Inject ( MAT_RIPPLE_GLOBAL_OPTIONS )
228
- globalRippleOptions : RippleGlobalOptions | null ) {
233
+ globalRippleOptions : RippleGlobalOptions | null ,
234
+ // @breaking -change 7.0.0 `animationMode` parameter to become required.
235
+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) animationMode ?: string ) {
229
236
super ( _elementRef ) ;
230
237
231
238
this . _addHostClassName ( ) ;
232
239
233
240
this . _chipRipple = new RippleRenderer ( this , _ngZone , _elementRef , platform ) ;
234
241
this . _chipRipple . setupTriggerEvents ( _elementRef . nativeElement ) ;
235
242
this . rippleConfig = globalRippleOptions || { } ;
243
+ this . _animationsDisabled = animationMode === 'NoopAnimations' ;
236
244
}
237
245
238
246
_addHostClassName ( ) {
247
+ const element = this . _elementRef . nativeElement ;
248
+
239
249
// Add class for the different chips
240
250
for ( const attr of CHIP_ATTRIBUTE_NAMES ) {
241
- if ( this . _elementRef . nativeElement . hasAttribute ( attr ) ||
242
- this . _elementRef . nativeElement . tagName . toLowerCase ( ) === attr ) {
243
- ( this . _elementRef . nativeElement as HTMLElement ) . classList . add ( attr ) ;
251
+ if ( element . hasAttribute ( attr ) || element . tagName . toLowerCase ( ) === attr ) {
252
+ element . classList . add ( attr ) ;
244
253
return ;
245
254
}
246
255
}
247
- ( this . _elementRef . nativeElement as HTMLElement ) . classList . add ( 'mat-standard-chip' ) ;
256
+ element . classList . add ( 'mat-standard-chip' ) ;
248
257
}
249
258
250
259
ngOnDestroy ( ) {
0 commit comments