@@ -33,10 +33,6 @@ import {MDCChipFoundation} from './foundation';
3333import { MDCChipInteractionEventDetail , MDCChipNavigationEventDetail , MDCChipRemovalEventDetail ,
3434 MDCChipSelectionEventDetail } from './types' ;
3535
36- type InteractionType = 'click' | 'keydown' ;
37-
38- const INTERACTION_EVENTS : InteractionType [ ] = [ 'click' , 'keydown' ] ;
39-
4036export type MDCChipFactory = ( el : Element , foundation ?: MDCChipFoundation ) => MDCChip ;
4137
4238export class MDCChip extends MDCComponent < MDCChipFoundation > implements MDCRippleCapableSurface {
@@ -84,20 +80,17 @@ export class MDCChip extends MDCComponent<MDCChipFoundation> implements MDCRippl
8480 root_ ! : HTMLElement ; // assigned in MDCComponent constructor
8581
8682 private leadingIcon_ ! : Element | null ; // assigned in initialize()
87- private trailingIcon_ ! : Element | null ; // assigned in initialize()
8883 private checkmark_ ! : Element | null ; // assigned in initialize()
8984 private ripple_ ! : MDCRipple ; // assigned in initialize()
9085 private primaryAction_ ! : Element | null ; // assigned in initialize()
9186 private trailingAction_ ! : Element | null ; // assigned in initialize()
9287
93- private handleInteraction_ ! : SpecificEventListener < InteractionType > ; // assigned in initialSyncWithDOM()
88+ private handleClick_ ! : SpecificEventListener < 'click' > ; // assigned in initialSyncWithDOM()
9489 private handleTransitionEnd_ ! : SpecificEventListener < 'transitionend' > ; // assigned in initialSyncWithDOM()
95- private handleTrailingIconInteraction_ ! : SpecificEventListener < InteractionType > ; // assigned in initialSyncWithDOM()
9690 private handleKeydown_ ! : SpecificEventListener < 'keydown' > ; // assigned in initialSyncWithDOM()
9791
9892 initialize ( rippleFactory : MDCRippleFactory = ( el , foundation ) => new MDCRipple ( el , foundation ) ) {
9993 this . leadingIcon_ = this . root_ . querySelector ( strings . LEADING_ICON_SELECTOR ) ;
100- this . trailingIcon_ = this . root_ . querySelector ( strings . TRAILING_ICON_SELECTOR ) ;
10194 this . checkmark_ = this . root_ . querySelector ( strings . CHECKMARK_SELECTOR ) ;
10295 this . primaryAction_ = this . root_ . querySelector ( strings . PRIMARY_ACTION_SELECTOR ) ;
10396 this . trailingAction_ = this . root_ . querySelector ( strings . TRAILING_ACTION_SELECTOR ) ;
@@ -112,40 +105,21 @@ export class MDCChip extends MDCComponent<MDCChipFoundation> implements MDCRippl
112105 }
113106
114107 initialSyncWithDOM ( ) {
115- this . handleInteraction_ = ( evt : MouseEvent | KeyboardEvent ) => this . foundation_ . handleInteraction ( evt ) ;
108+ this . handleClick_ = ( evt : MouseEvent ) => this . foundation_ . handleClick ( evt ) ;
116109 this . handleTransitionEnd_ = ( evt : TransitionEvent ) => this . foundation_ . handleTransitionEnd ( evt ) ;
117- this . handleTrailingIconInteraction_ = ( evt : MouseEvent | KeyboardEvent ) =>
118- this . foundation_ . handleTrailingIconInteraction ( evt ) ;
119110 this . handleKeydown_ = ( evt : KeyboardEvent ) => this . foundation_ . handleKeydown ( evt ) ;
120111
121- INTERACTION_EVENTS . forEach ( ( evtType ) => {
122- this . listen ( evtType , this . handleInteraction_ ) ;
123- } ) ;
112+ this . listen ( 'click' , this . handleClick_ ) ;
124113 this . listen ( 'transitionend' , this . handleTransitionEnd_ ) ;
125114 this . listen ( 'keydown' , this . handleKeydown_ ) ;
126-
127- if ( this . trailingIcon_ ) {
128- INTERACTION_EVENTS . forEach ( ( evtType ) => {
129- this . trailingIcon_ ! . addEventListener ( evtType , this . handleTrailingIconInteraction_ as EventListener ) ;
130- } ) ;
131- }
132115 }
133116
134117 destroy ( ) {
135118 this . ripple_ . destroy ( ) ;
136-
137- INTERACTION_EVENTS . forEach ( ( evtType ) => {
138- this . unlisten ( evtType , this . handleInteraction_ ) ;
139- } ) ;
119+ this . unlisten ( 'click' , this . handleClick_ ) ;
140120 this . unlisten ( 'transitionend' , this . handleTransitionEnd_ ) ;
141121 this . unlisten ( 'keydown' , this . handleKeydown_ ) ;
142122
143- if ( this . trailingIcon_ ) {
144- INTERACTION_EVENTS . forEach ( ( evtType ) => {
145- this . trailingIcon_ ! . removeEventListener ( evtType , this . handleTrailingIconInteraction_ as EventListener ) ;
146- } ) ;
147- }
148-
149123 super . destroy ( ) ;
150124 }
151125
0 commit comments