-
Notifications
You must be signed in to change notification settings - Fork 24.7k
/
dom_events.ts
30 lines (25 loc) 路 993 Bytes
/
dom_events.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Injectable} from '@angular/core';
import {EventManagerPlugin} from './event_manager';
@Injectable()
export class DomEventsPlugin extends EventManagerPlugin {
// This plugin should come last in the list of plugins, because it accepts all
// events.
override supports(eventName: string): boolean {
return true;
}
override addEventListener(
element: HTMLElement, eventName: string, handler: (event: Event) => void): () => void {
element.addEventListener(eventName, handler as EventListener, false);
return () => this.removeEventListener(element, eventName, handler as EventListener);
}
removeEventListener(target: any, eventName: string, callback: Function): void {
return target.removeEventListener(eventName, callback as EventListener);
}
}