|
22 | 22 | */
|
23 | 23 |
|
24 | 24 | import {MDCComponent} from '@material/base/component';
|
25 |
| -import {EventType} from '@material/base/types'; |
| 25 | +import {EventType, SpecificEventListener} from '@material/base/types'; |
26 | 26 | import {applyPassive} from '@material/dom/events';
|
27 | 27 | import {matches} from '@material/dom/ponyfill';
|
28 | 28 | import {MDCRippleAdapter} from '@material/ripple/adapter';
|
@@ -104,15 +104,19 @@ export class MDCSwitch extends MDCComponent<MDCSwitchFoundation> implements MDCR
|
104 | 104 | ...MDCRipple.createAdapter(this),
|
105 | 105 | addClass: (className: string) => rippleSurface.classList.add(className),
|
106 | 106 | computeBoundingRect: () => rippleSurface.getBoundingClientRect(),
|
107 |
| - deregisterInteractionHandler: (evtType: EventType, handler: EventListener) => { |
| 107 | + deregisterInteractionHandler: <K extends EventType>( |
| 108 | + evtType: K, handler: SpecificEventListener<K>) => { |
108 | 109 | this.nativeControl_.removeEventListener(evtType, handler, applyPassive());
|
109 | 110 | },
|
110 | 111 | isSurfaceActive: () => matches(this.nativeControl_, ':active'),
|
111 | 112 | isUnbounded: () => true,
|
112 |
| - registerInteractionHandler: (evtType: EventType, handler: EventListener) => { |
| 113 | + registerInteractionHandler: <K extends EventType>( |
| 114 | + evtType: K, handler: SpecificEventListener<K>) => { |
113 | 115 | this.nativeControl_.addEventListener(evtType, handler, applyPassive());
|
114 | 116 | },
|
115 |
| - removeClass: (className: string) => rippleSurface.classList.remove(className), |
| 117 | + removeClass: (className: string) => { |
| 118 | + rippleSurface.classList.remove(className); |
| 119 | + }, |
116 | 120 | updateCssVariable: (varName: string, value: string) => {
|
117 | 121 | rippleSurface.style.setProperty(varName, value);
|
118 | 122 | },
|
|
0 commit comments