@@ -24,14 +24,14 @@ import {
2424} from './ReactDOMComponentTree' ;
2525import { ELEMENT_NODE } from '../shared/HTMLNodeType' ;
2626import {
27- listenToTopLevelEvent ,
27+ listenToNativeEvent ,
2828 addEventTypeToDispatchConfig ,
2929} from '../events/DOMModernPluginEventSystem' ;
3030
3131import { HostRoot , HostPortal } from 'react-reconciler/src/ReactWorkTags' ;
3232import {
3333 PLUGIN_EVENT_SYSTEM ,
34- IS_TARGET_PHASE_ONLY ,
34+ IS_EVENT_HANDLE_NON_MANAGED_NODE ,
3535} from '../events/EventSystemFlags' ;
3636
3737import {
@@ -71,22 +71,22 @@ function isReactScope(target: EventTarget | ReactScopeInstance): boolean {
7171
7272function createEventHandleListener (
7373 type : DOMTopLevelEventType ,
74- capture : boolean ,
74+ isCapturePhaseListener : boolean ,
7575 callback : ( SyntheticEvent < EventTarget > ) => void ,
7676) : ReactDOMEventHandleListener {
7777 return {
7878 callback,
79- capture,
79+ capture : isCapturePhaseListener ,
8080 type,
8181 } ;
8282}
8383
8484function registerEventOnNearestTargetContainer (
8585 targetFiber : Fiber ,
8686 topLevelType : DOMTopLevelEventType ,
87- passive : boolean | void ,
88- priority : EventPriority | void ,
89- capture : boolean ,
87+ isPassiveListener : boolean | void ,
88+ listenerPriority : EventPriority | void ,
89+ isCapturePhaseListener : boolean ,
9090) : void {
9191 // If it is, find the nearest root or portal and make it
9292 // our event handle target container.
@@ -99,23 +99,23 @@ function registerEventOnNearestTargetContainer(
9999 ) ;
100100 }
101101 const listenerMap = getEventListenerMap ( targetContainer ) ;
102- listenToTopLevelEvent (
102+ listenToNativeEvent (
103103 topLevelType ,
104104 targetContainer ,
105105 listenerMap ,
106106 PLUGIN_EVENT_SYSTEM ,
107- capture ,
108- passive ,
109- priority ,
107+ isCapturePhaseListener ,
108+ isPassiveListener ,
109+ listenerPriority ,
110110 ) ;
111111}
112112
113113function registerReactDOMEvent (
114114 target : EventTarget | ReactScopeInstance ,
115115 topLevelType : DOMTopLevelEventType ,
116- passive : boolean | void ,
117- capture : boolean ,
118- priority : EventPriority | void ,
116+ isPassiveListener : boolean | void ,
117+ isCapturePhaseListener : boolean ,
118+ listenerPriority : EventPriority | void ,
119119) : void {
120120 // Check if the target is a DOM element.
121121 if ( ( target : any ) . nodeType === ELEMENT_NODE ) {
@@ -132,9 +132,9 @@ function registerReactDOMEvent(
132132 registerEventOnNearestTargetContainer (
133133 targetFiber ,
134134 topLevelType ,
135- passive ,
136- priority ,
137- capture ,
135+ isPassiveListener ,
136+ listenerPriority ,
137+ isCapturePhaseListener ,
138138 ) ;
139139 } else if ( enableScopeAPI && isReactScope ( target ) ) {
140140 const scopeTarget = ( ( target : any ) : ReactScopeInstance ) ;
@@ -146,21 +146,21 @@ function registerReactDOMEvent(
146146 registerEventOnNearestTargetContainer (
147147 targetFiber ,
148148 topLevelType ,
149- passive ,
150- priority ,
151- capture ,
149+ isPassiveListener ,
150+ listenerPriority ,
151+ isCapturePhaseListener ,
152152 ) ;
153153 } else if ( isValidEventTarget ( target ) ) {
154154 const eventTarget = ( ( target : any ) : EventTarget ) ;
155155 const listenerMap = getEventListenerMap ( eventTarget ) ;
156- listenToTopLevelEvent (
156+ listenToNativeEvent (
157157 topLevelType ,
158158 eventTarget ,
159159 listenerMap ,
160- PLUGIN_EVENT_SYSTEM | IS_TARGET_PHASE_ONLY ,
161- capture ,
162- passive ,
163- priority ,
160+ PLUGIN_EVENT_SYSTEM | IS_EVENT_HANDLE_NON_MANAGED_NODE ,
161+ isCapturePhaseListener ,
162+ isPassiveListener ,
163+ listenerPriority ,
164164 ) ;
165165 } else {
166166 invariant (
@@ -177,27 +177,27 @@ export function createEventHandle(
177177) : ReactDOMEventHandle {
178178 if ( enableCreateEventHandleAPI ) {
179179 const topLevelType = ( ( type : any ) : DOMTopLevelEventType ) ;
180- let capture = false ;
181- let passive = undefined ; // Undefined means to use the browser default
182- let priority ;
180+ let isCapturePhaseListener = false ;
181+ let isPassiveListener = undefined ; // Undefined means to use the browser default
182+ let listenerPriority ;
183183
184184 if ( options != null ) {
185185 const optionsCapture = options . capture ;
186186 const optionsPassive = options . passive ;
187187 const optionsPriority = options . priority ;
188188
189189 if ( typeof optionsCapture === 'boolean' ) {
190- capture = optionsCapture ;
190+ isCapturePhaseListener = optionsCapture ;
191191 }
192192 if ( typeof optionsPassive === 'boolean' ) {
193- passive = optionsPassive ;
193+ isPassiveListener = optionsPassive ;
194194 }
195195 if ( typeof optionsPriority === 'number' ) {
196- priority = optionsPriority ;
196+ listenerPriority = optionsPriority ;
197197 }
198198 }
199- if ( priority === undefined ) {
200- priority = getEventPriorityForListenerSystem ( topLevelType ) ;
199+ if ( listenerPriority === undefined ) {
200+ listenerPriority = getEventPriorityForListenerSystem ( topLevelType ) ;
201201 }
202202
203203 const registeredReactDOMEvents = new PossiblyWeakSet ( ) ;
@@ -213,13 +213,19 @@ export function createEventHandle(
213213 ) ;
214214 if ( ! registeredReactDOMEvents . has ( target ) ) {
215215 registeredReactDOMEvents . add ( target ) ;
216- registerReactDOMEvent ( target , topLevelType , passive , capture , priority ) ;
216+ registerReactDOMEvent (
217+ target ,
218+ topLevelType ,
219+ isPassiveListener ,
220+ isCapturePhaseListener ,
221+ listenerPriority ,
222+ ) ;
217223 // Add the event to our known event types list.
218224 addEventTypeToDispatchConfig ( topLevelType ) ;
219225 }
220226 const listener = createEventHandleListener (
221227 topLevelType ,
222- capture ,
228+ isCapturePhaseListener ,
223229 callback ,
224230 ) ;
225231 let targetListeners = getEventHandlerListeners ( target ) ;
0 commit comments