File tree 1 file changed +8
-19
lines changed
1 file changed +8
-19
lines changed Original file line number Diff line number Diff line change @@ -9,21 +9,15 @@ const findEventHandler = (
9
9
nearestHostDescendent ? : ReactTestInstance
10
10
) => {
11
11
const isHostComponent = typeof element . type === 'string' ;
12
- const nearestHostComponent = isHostComponent
13
- ? element
14
- : nearestHostDescendent ;
12
+ const hostElement = isHostComponent ? element : nearestHostDescendent ;
13
+ const isEventEnabled =
14
+ hostElement ?. props . onStartShouldSetResponder ?. ( ) !== false ;
15
15
16
- const eventHandler = toEventHandlerName ( eventName ) ;
16
+ const eventHandlerName = toEventHandlerName ( eventName ) ;
17
17
18
- if (
19
- typeof element . props [ eventHandler ] === 'function' &&
20
- nearestHostComponent ?. props . onStartShouldSetResponder ?. ( ) !== false
21
- ) {
22
- return element . props [ eventHandler ] ;
23
- } else if (
24
- typeof element . props [ eventName ] === 'function' &&
25
- nearestHostComponent ?. props . onStartShouldSetResponder ?. ( ) !== false
26
- ) {
18
+ if ( typeof element . props [ eventHandlerName ] === 'function' && isEventEnabled ) {
19
+ return element . props [ eventHandlerName ] ;
20
+ } else if ( typeof element . props [ eventName ] === 'function' && isEventEnabled ) {
27
21
return element . props [ eventName ] ;
28
22
}
29
23
@@ -35,12 +29,7 @@ const findEventHandler = (
35
29
) ;
36
30
}
37
31
38
- return findEventHandler (
39
- element . parent ,
40
- eventName ,
41
- callsite ,
42
- nearestHostComponent
43
- ) ;
32
+ return findEventHandler ( element . parent , eventName , callsite , hostElement ) ;
44
33
} ;
45
34
46
35
const invokeEvent = (
You can’t perform that action at this time.
0 commit comments