|
7 | 7 | */ |
8 | 8 |
|
9 | 9 | // tslint:disable:no-duplicate-imports |
10 | | -import { |
11 | | - EventContract, |
12 | | - EventContractContainer, |
13 | | - EventDispatcher, |
14 | | - isEarlyEventType, |
15 | | - getActionCache, |
16 | | - registerDispatcher, |
17 | | -} from '@angular/core/primitives/event-dispatch'; |
| 10 | +import {EventContract} from '@angular/core/primitives/event-dispatch'; |
18 | 11 | import {Attribute} from '@angular/core/primitives/event-dispatch'; |
19 | | -import {Injectable, InjectionToken, Injector, inject} from './di'; |
| 12 | +import {InjectionToken} from './di'; |
20 | 13 | import {RElement} from './render3/interfaces/renderer_dom'; |
21 | | -import {EVENT_REPLAY_ENABLED_DEFAULT, IS_EVENT_REPLAY_ENABLED} from './hydration/tokens'; |
22 | | -import {OnDestroy} from './interface/lifecycle_hooks'; |
23 | 14 |
|
24 | 15 | declare global { |
25 | 16 | interface Element { |
@@ -71,60 +62,3 @@ export const JSACTION_EVENT_CONTRACT = new InjectionToken<EventContractDetails>( |
71 | 62 | factory: () => ({}), |
72 | 63 | }, |
73 | 64 | ); |
74 | | - |
75 | | -export const GLOBAL_EVENT_DELEGATION = new InjectionToken<GlobalEventDelegation>( |
76 | | - ngDevMode ? 'GLOBAL_EVENT_DELEGATION' : '', |
77 | | -); |
78 | | - |
79 | | -/** |
80 | | - * This class is the delegate for `EventDelegationPlugin`. It represents the |
81 | | - * noop version of this class, with the enabled version set when |
82 | | - * `provideGlobalEventDelegation` is called. |
83 | | - */ |
84 | | -@Injectable() |
85 | | -export class GlobalEventDelegation implements OnDestroy { |
86 | | - private eventContractDetails = inject(JSACTION_EVENT_CONTRACT); |
87 | | - |
88 | | - ngOnDestroy() { |
89 | | - this.eventContractDetails.instance?.cleanUp(); |
90 | | - } |
91 | | - |
92 | | - supports(eventType: string): boolean { |
93 | | - return isEarlyEventType(eventType); |
94 | | - } |
95 | | - |
96 | | - addEventListener(element: HTMLElement, eventType: string, handler: Function): Function { |
97 | | - // Note: contrary to the type, Window and Document can be passed in |
98 | | - // as well. |
99 | | - if (element.nodeType === Node.ELEMENT_NODE) { |
100 | | - this.eventContractDetails.instance!.addEvent(eventType); |
101 | | - getActionCache(element)[eventType] = ''; |
102 | | - sharedStashFunction(element, eventType, handler); |
103 | | - } else { |
104 | | - element.addEventListener(eventType, handler as EventListener); |
105 | | - } |
106 | | - return () => this.removeEventListener(element, eventType, handler); |
107 | | - } |
108 | | - |
109 | | - removeEventListener(element: HTMLElement, eventType: string, callback: Function): void { |
110 | | - if (element.nodeType === Node.ELEMENT_NODE) { |
111 | | - getActionCache(element)[eventType] = undefined; |
112 | | - } else { |
113 | | - element.removeEventListener(eventType, callback as EventListener); |
114 | | - } |
115 | | - } |
116 | | -} |
117 | | - |
118 | | -export const initGlobalEventDelegation = ( |
119 | | - eventContractDetails: EventContractDetails, |
120 | | - injector: Injector, |
121 | | -) => { |
122 | | - if (injector.get(IS_EVENT_REPLAY_ENABLED, EVENT_REPLAY_ENABLED_DEFAULT)) { |
123 | | - return; |
124 | | - } |
125 | | - const eventContract = (eventContractDetails.instance = new EventContract( |
126 | | - new EventContractContainer(document.body), |
127 | | - )); |
128 | | - const dispatcher = new EventDispatcher(invokeRegisteredListeners, /** clickModSupport */ false); |
129 | | - registerDispatcher(eventContract, dispatcher); |
130 | | -}; |
0 commit comments