@@ -17,6 +17,13 @@ import {
1717
1818import { RuntimeErrorCode } from '../../errors' ;
1919
20+ import type { EventManagerPlugin } from './event_manager_plugin' ;
21+
22+ // Temporart re-export until we can change files that import from this file in G3.
23+ export { EventManagerPlugin } from './event_manager_plugin' ;
24+
25+ import { DomEventsPlugin } from './dom_events' ;
26+
2027/**
2128 * The injection token for plugins of the `EventManager` service.
2229 *
@@ -47,7 +54,15 @@ export class EventManager {
4754 plugins . forEach ( ( plugin ) => {
4855 plugin . manager = this ;
4956 } ) ;
50- this . _plugins = plugins . slice ( ) . reverse ( ) ;
57+
58+ const otherPlugins = plugins . filter ( ( p ) => ! ( p instanceof DomEventsPlugin ) ) ;
59+ this . _plugins = otherPlugins . slice ( ) . reverse ( ) ;
60+
61+ // DomEventsPlugin.supports() always returns true, it should always be the last plugin.
62+ const domEventPlugin = plugins . find ( ( p ) => p instanceof DomEventsPlugin ) ;
63+ if ( domEventPlugin ) {
64+ this . _plugins . push ( domEventPlugin ) ;
65+ }
5166 }
5267
5368 /**
@@ -98,34 +113,3 @@ export class EventManager {
98113 return plugin ;
99114 }
100115}
101-
102- /**
103- * The plugin definition for the `EventManager` class
104- *
105- * It can be used as a base class to create custom manager plugins, i.e. you can create your own
106- * class that extends the `EventManagerPlugin` one.
107- *
108- * @publicApi
109- */
110- export abstract class EventManagerPlugin {
111- // TODO: remove (has some usage in G3)
112- constructor ( private _doc : any ) { }
113-
114- // Using non-null assertion because it's set by EventManager's constructor
115- manager ! : EventManager ;
116-
117- /**
118- * Should return `true` for every event name that should be supported by this plugin
119- */
120- abstract supports ( eventName : string ) : boolean ;
121-
122- /**
123- * Implement the behaviour for the supported events
124- */
125- abstract addEventListener (
126- element : HTMLElement ,
127- eventName : string ,
128- handler : Function ,
129- options ?: ListenerOptions ,
130- ) : Function ;
131- }
0 commit comments