@@ -14,6 +14,18 @@ import {REACT_EVENT_TARGET_TOUCH_HIT} from 'shared/ReactSymbols';
14
14
15
15
import { enableEventAPI } from 'shared/ReactFeatureFlags' ;
16
16
17
+ type EventTargetChildElement = {
18
+ type : string ,
19
+ props : null | {
20
+ style ?: {
21
+ position ?: string ,
22
+ bottom ?: string ,
23
+ left ?: string ,
24
+ right ?: string ,
25
+ top ?: string ,
26
+ } ,
27
+ } ,
28
+ } ;
17
29
export type Type = string ;
18
30
export type Props = Object ;
19
31
export type Container = { |
@@ -170,12 +182,6 @@ export function createInstance(
170
182
hostContext : Object ,
171
183
internalInstanceHandle : Object ,
172
184
) : Instance {
173
- if ( __DEV__ && enableEventAPI ) {
174
- warning (
175
- hostContext !== EVENT_TOUCH_HIT_TARGET_CONTEXT ,
176
- 'validateDOMNesting: <TouchHitTarget> must not have any children.' ,
177
- ) ;
178
- }
179
185
return {
180
186
type ,
181
187
props ,
@@ -233,10 +239,6 @@ export function createTextInstance(
233
239
internalInstanceHandle : Object ,
234
240
) : TextInstance {
235
241
if ( __DEV__ && enableEventAPI ) {
236
- warning (
237
- hostContext !== EVENT_TOUCH_HIT_TARGET_CONTEXT ,
238
- 'validateDOMNesting: <TouchHitTarget> must not have any children.' ,
239
- ) ;
240
242
warning (
241
243
hostContext !== EVENT_COMPONENT_CONTEXT ,
242
244
'validateDOMNesting: React event components cannot have text DOM nodes as children. ' +
@@ -329,17 +331,62 @@ export function handleEventComponent(
329
331
eventResponder : ReactEventResponder ,
330
332
rootContainerInstance : Container ,
331
333
internalInstanceHandle : Object ,
332
- ) {
333
- // TODO: add handleEventComponent implementation
334
+ ) : void {
335
+ // noop
336
+ }
337
+
338
+ export function getEventTargetChildElement (
339
+ type : Symbol | number ,
340
+ props : Props ,
341
+ ) : null | EventTargetChildElement {
342
+ if ( enableEventAPI ) {
343
+ if ( type === REACT_EVENT_TARGET_TOUCH_HIT ) {
344
+ const { bottom , left , right , top } = props ;
345
+
346
+ if ( ! bottom && ! left && ! right && ! top ) {
347
+ return null ;
348
+ }
349
+ return {
350
+ type : 'div ',
351
+ props : {
352
+ style : {
353
+ position : 'absolute ',
354
+ zIndex : - 1 ,
355
+ bottom : bottom ? `- $ { bottom } px ` : '0 px ',
356
+ left : left ? `- $ { left } px ` : '0 px ',
357
+ right : right ? `- $ { right } px ` : '0 px ',
358
+ top : top ? `- $ { top } px ` : '0 px ',
359
+ } ,
360
+ } ,
361
+ } ;
362
+ }
363
+ }
364
+ return null ;
334
365
}
335
366
336
367
export function handleEventTarget (
337
368
type : Symbol | number ,
338
369
props : Props ,
339
- parentInstance : Container ,
370
+ rootContainerInstance : Container ,
340
371
internalInstanceHandle : Object ,
341
- ) {
342
- if ( type === REACT_EVENT_TARGET_TOUCH_HIT ) {
343
- // TODO
372
+ ) : boolean {
373
+ if ( enableEventAPI ) {
374
+ if ( type === REACT_EVENT_TARGET_TOUCH_HIT ) {
375
+ // In DEV we do a computed style check on the position to ensure
376
+ // the parent host component is correctly position in the document.
377
+ if ( __DEV__ ) {
378
+ return true ;
379
+ }
380
+ }
344
381
}
382
+ return false ;
383
+ }
384
+
385
+ export function commitEventTarget (
386
+ type : Symbol | number ,
387
+ props : Props ,
388
+ instance : Instance ,
389
+ parentInstance : Instance ,
390
+ ) : void {
391
+ // noop
345
392
}
0 commit comments