Skip to content

Commit 8b88ac2

Browse files
authored
[Flare] Remove event targets including TouchHitTarget (facebook#16011)
1 parent f115409 commit 8b88ac2

36 files changed

+18
-1789
lines changed

packages/react-art/src/ReactARTHostConfig.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,6 @@ export function getChildHostContextForEventComponent() {
333333
return NO_CONTEXT;
334334
}
335335

336-
export function getChildHostContextForEventTarget() {
337-
return NO_CONTEXT;
338-
}
339-
340336
export const scheduleTimeout = setTimeout;
341337
export const cancelTimeout = clearTimeout;
342338
export const noTimeout = -1;

packages/react-dom/src/client/ReactDOMComponent.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ let didWarnShadyDOM = false;
9797
const DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML';
9898
const SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning';
9999
const SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
100-
const HYDRATE_TOUCH_HIT_TARGET = 'hydrateTouchHitTarget';
101100
const AUTOFOCUS = 'autoFocus';
102101
const CHILDREN = 'children';
103102
const STYLE = 'style';
@@ -1034,8 +1033,6 @@ export function diffHydratedProperties(
10341033
}
10351034
ensureListeningTo(rootContainerElement, propKey);
10361035
}
1037-
} else if (enableEventAPI && propKey === HYDRATE_TOUCH_HIT_TARGET) {
1038-
updatePayload = [STYLE, rawProps.style];
10391036
} else if (
10401037
__DEV__ &&
10411038
// Convince Flow we've calculated it (it's DEV-only in this method.)

packages/react-dom/src/client/ReactDOMHostConfig.js

Lines changed: 1 addition & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
isEnabled as ReactBrowserEventEmitterIsEnabled,
3232
setEnabled as ReactBrowserEventEmitterSetEnabled,
3333
} from '../events/ReactBrowserEventEmitter';
34-
import {Namespaces, getChildNamespace} from '../shared/DOMNamespaces';
34+
import {getChildNamespace} from '../shared/DOMNamespaces';
3535
import {addRootEventTypesForComponentInstance} from '../events/DOMEventResponderSystem';
3636
import {
3737
ELEMENT_NODE,
@@ -51,8 +51,6 @@ import {
5151
mountEventResponder,
5252
unmountEventResponder,
5353
} from '../events/DOMEventResponderSystem';
54-
import {REACT_EVENT_TARGET_TOUCH_HIT} from 'shared/ReactSymbols';
55-
import {canUseDOM} from 'shared/ExecutionEnvironment';
5654

5755
export type Type = string;
5856
export type Props = {
@@ -93,7 +91,6 @@ type HostContextDev = {
9391
ancestorInfo: mixed,
9492
eventData: null | {|
9593
isEventComponent?: boolean,
96-
isEventTarget?: boolean,
9794
|},
9895
};
9996
type HostContextProd = string;
@@ -109,8 +106,6 @@ import {
109106
} from 'shared/ReactFeatureFlags';
110107
import warning from 'shared/warning';
111108

112-
const {html: HTML_NAMESPACE} = Namespaces;
113-
114109
let SUPPRESS_HYDRATION_WARNING;
115110
if (__DEV__) {
116111
SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
@@ -196,45 +191,8 @@ export function getChildHostContextForEventComponent(
196191
if (__DEV__) {
197192
const parentHostContextDev = ((parentHostContext: any): HostContextDev);
198193
const {namespace, ancestorInfo} = parentHostContextDev;
199-
warning(
200-
parentHostContextDev.eventData === null ||
201-
!parentHostContextDev.eventData.isEventTarget,
202-
'validateDOMNesting: React event targets must not have event components as children.',
203-
);
204194
const eventData = {
205195
isEventComponent: true,
206-
isEventTarget: false,
207-
};
208-
return {namespace, ancestorInfo, eventData};
209-
}
210-
return parentHostContext;
211-
}
212-
213-
export function getChildHostContextForEventTarget(
214-
parentHostContext: HostContext,
215-
type: Symbol | number,
216-
): HostContext {
217-
if (__DEV__) {
218-
const parentHostContextDev = ((parentHostContext: any): HostContextDev);
219-
const {namespace, ancestorInfo} = parentHostContextDev;
220-
if (type === REACT_EVENT_TARGET_TOUCH_HIT) {
221-
warning(
222-
parentHostContextDev.eventData === null ||
223-
!parentHostContextDev.eventData.isEventComponent,
224-
'validateDOMNesting: <TouchHitTarget> cannot not be a direct child of an event component. ' +
225-
'Ensure <TouchHitTarget> is a direct child of a DOM element.',
226-
);
227-
const parentNamespace = parentHostContextDev.namespace;
228-
if (parentNamespace !== HTML_NAMESPACE) {
229-
throw new Error(
230-
'<TouchHitTarget> was used in an unsupported DOM namespace. ' +
231-
'Ensure the <TouchHitTarget> is used in an HTML namespace.',
232-
);
233-
}
234-
}
235-
const eventData = {
236-
isEventComponent: false,
237-
isEventTarget: true,
238196
};
239197
return {namespace, ancestorInfo, eventData};
240198
}
@@ -924,85 +882,3 @@ export function unmountEventComponent(
924882
unmountEventResponder(eventComponentInstance);
925883
}
926884
}
927-
928-
export function getEventTargetChildElement(
929-
type: Symbol | number,
930-
props: Props,
931-
): null | EventTargetChildElement {
932-
if (enableEventAPI) {
933-
if (type === REACT_EVENT_TARGET_TOUCH_HIT) {
934-
const {bottom, left, right, top} = props;
935-
936-
if (!bottom && !left && !right && !top) {
937-
return null;
938-
}
939-
return {
940-
type: 'div',
941-
props: {
942-
style: {
943-
position: 'absolute',
944-
zIndex: -1,
945-
pointerEvents: null,
946-
bottom: bottom ? `-${bottom}px` : '0px',
947-
left: left ? `-${left}px` : '0px',
948-
right: right ? `-${right}px` : '0px',
949-
top: top ? `-${top}px` : '0px',
950-
},
951-
hydrateTouchHitTarget: true,
952-
suppressHydrationWarning: true,
953-
},
954-
};
955-
}
956-
}
957-
return null;
958-
}
959-
960-
export function handleEventTarget(
961-
type: Symbol | number,
962-
props: Props,
963-
rootContainerInstance: Container,
964-
internalInstanceHandle: Object,
965-
): boolean {
966-
if (
967-
__DEV__ &&
968-
type === REACT_EVENT_TARGET_TOUCH_HIT &&
969-
(props.left || props.right || props.top || props.bottom)
970-
) {
971-
return true;
972-
}
973-
return false;
974-
}
975-
976-
export function commitEventTarget(
977-
type: Symbol | number,
978-
props: Props,
979-
instance: Instance,
980-
parentInstance: Instance,
981-
): void {
982-
if (enableEventAPI) {
983-
if (type === REACT_EVENT_TARGET_TOUCH_HIT) {
984-
if (__DEV__ && canUseDOM) {
985-
// This is done at DEV time because getComputedStyle will
986-
// typically force a style recalculation and force a layout,
987-
// reflow -– both of which are sync are expensive.
988-
const computedStyles = window.getComputedStyle(parentInstance);
989-
const position = computedStyles.getPropertyValue('position');
990-
warning(
991-
position !== '' && position !== 'static',
992-
'<TouchHitTarget> inserts an empty absolutely positioned <div>. ' +
993-
'This requires its parent DOM node to be positioned too, but the ' +
994-
'parent DOM node was found to have the style "position" set to ' +
995-
'either no value, or a value of "static". Try using a "position" ' +
996-
'value of "relative".',
997-
);
998-
warning(
999-
computedStyles.getPropertyValue('z-index') !== '',
1000-
'<TouchHitTarget> inserts an empty <div> with "z-index" of "-1". ' +
1001-
'This requires its parent DOM node to have a "z-index" greater than "-1",' +
1002-
'but the parent DOM node was found to no "z-index" value set.' +
1003-
' Try using a "z-index" value of "0" or greater.',
1004-
);
1005-
}
1006-
}
1007-
}
1008-
}

packages/react-dom/src/events/DOMEventResponderSystem.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
import type {AnyNativeEvent} from 'events/PluginModuleType';
1515
import {
1616
EventComponent,
17-
EventTarget as EventTargetWorkTag,
1817
HostComponent,
1918
FunctionComponent,
2019
} from 'shared/ReactWorkTags';
@@ -182,35 +181,6 @@ const eventResponderContext: ReactDOMResponderContext = {
182181
eventListeners.set(eventObject, listener);
183182
eventQueue.events.push(eventObject);
184183
},
185-
isEventWithinTouchHitTarget(event: ReactDOMResponderEvent): boolean {
186-
validateResponderContext();
187-
const target = event.target;
188-
const nativeEvent = event.nativeEvent;
189-
// We should always be dealing with a mouse event or touch event here.
190-
// If we are not, these won't exist and we can early return.
191-
const x = (nativeEvent: any).clientX;
192-
const y = (nativeEvent: any).clientY;
193-
if (x === undefined || y === undefined) {
194-
return false;
195-
}
196-
const childFiber = getClosestInstanceFromNode(target);
197-
if (childFiber === null) {
198-
return false;
199-
}
200-
const parentFiber = childFiber.return;
201-
if (parentFiber !== null && parentFiber.tag === EventTargetWorkTag) {
202-
const parentNode = ((target.parentNode: any): Element);
203-
// TODO find another way to do this without using the
204-
// expensive getBoundingClientRect.
205-
const {left, top, right, bottom} = parentNode.getBoundingClientRect();
206-
// Check if the co-ords intersect with the target element's rect.
207-
if (x > left && y > top && x < right && y < bottom) {
208-
return false;
209-
}
210-
return true;
211-
}
212-
return false;
213-
},
214184
isTargetWithinEventComponent(target: Element | Document): boolean {
215185
validateResponderContext();
216186
if (target != null) {

packages/react-dom/src/server/ReactPartialRenderer.js

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ import {
3939
REACT_LAZY_TYPE,
4040
REACT_MEMO_TYPE,
4141
REACT_EVENT_COMPONENT_TYPE,
42-
REACT_EVENT_TARGET_TYPE,
43-
REACT_EVENT_TARGET_TOUCH_HIT,
4442
} from 'shared/ReactSymbols';
4543

4644
import {
@@ -1168,32 +1166,8 @@ class ReactDOMServerRenderer {
11681166
this.stack.push(frame);
11691167
return '';
11701168
}
1171-
case REACT_EVENT_COMPONENT_TYPE:
1172-
case REACT_EVENT_TARGET_TYPE: {
1169+
case REACT_EVENT_COMPONENT_TYPE: {
11731170
if (enableEventAPI) {
1174-
if (
1175-
elementType.$$typeof === REACT_EVENT_TARGET_TYPE &&
1176-
elementType.type === REACT_EVENT_TARGET_TOUCH_HIT
1177-
) {
1178-
const props = nextElement.props;
1179-
const bottom = props.bottom || 0;
1180-
const left = props.left || 0;
1181-
const right = props.right || 0;
1182-
const top = props.top || 0;
1183-
1184-
if (bottom === 0 && left === 0 && right === 0 && top === 0) {
1185-
return '';
1186-
}
1187-
let topString = top ? `-${top}px` : '0px';
1188-
let leftString = left ? `-${left}px` : '0px';
1189-
let rightString = right ? `-${right}px` : '0x';
1190-
let bottomString = bottom ? `-${bottom}px` : '0px';
1191-
1192-
return (
1193-
`<div style="position:absolute;pointer-events:none;z-index:-1;bottom:` +
1194-
`${bottomString};left:${leftString};right:${rightString};top:${topString}"></div>`
1195-
);
1196-
}
11971171
const nextChildren = toArray(
11981172
((nextChild: any): ReactElement).props.children,
11991173
);

packages/react-dom/src/shared/DOMProperty.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ const properties = {};
219219
'suppressContentEditableWarning',
220220
'suppressHydrationWarning',
221221
'style',
222-
'hydrateTouchHitTarget',
223222
].forEach(name => {
224223
properties[name] = new PropertyInfoRecord(
225224
name,

packages/react-dom/src/shared/assertValidProps.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import warning from 'shared/warning';
1212
import ReactSharedInternals from 'shared/ReactSharedInternals';
1313

1414
import voidElementTags from './voidElementTags';
15-
import {enableEventAPI} from 'shared/ReactFeatureFlags';
16-
import {REACT_EVENT_TARGET_TYPE} from 'shared/ReactSymbols';
1715

1816
const HTML = '__html';
1917

@@ -29,11 +27,7 @@ function assertValidProps(tag: string, props: ?Object) {
2927
// Note the use of `==` which checks for null or undefined.
3028
if (voidElementTags[tag]) {
3129
invariant(
32-
(props.children == null ||
33-
(enableEventAPI &&
34-
props.children.type &&
35-
props.children.type.$$typeof === REACT_EVENT_TARGET_TYPE)) &&
36-
props.dangerouslySetInnerHTML == null,
30+
props.children == null && props.dangerouslySetInnerHTML == null,
3731
'%s is a void element tag and must neither have `children` nor ' +
3832
'use `dangerouslySetInnerHTML`.%s',
3933
tag,

packages/react-events/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ Component instance.
121121

122122
Returns `true` if the instance has taken ownership of the responder.
123123

124-
### isEventWithinTouchHitTarget(event: ResponderEvent): boolean
125-
126-
Returns `true` if the global coordinates lie within the TouchHitTarget.
127-
128124
### isTargetWithinElement(target: Element, element: Element): boolean
129125

130126
Returns `true` if `target` is a child of `element`.

packages/react-events/docs/Press.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Determines whether calling `onPress` should be cancelled if `onLongPress` or
119119

120120
Called immediately after a press is released, unless either 1) the press is
121121
released outside the hit bounds of the element (accounting for
122-
`pressRetentionOffset` and `TouchHitTarget`), or 2) the press was a long press,
122+
`pressRetentionOffset`), or 2) the press was a long press,
123123
and `onLongPress` or `onLongPressChange` props are provided, and
124124
`onLongPressCancelsPress()` is `true`.
125125

packages/react-events/index.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)