@samitouri / QOS-React-2 / commits / 80c4dea0d1

Modern Event System: Add scaffolding for createEventHandle (#18898)

Dominic Gannaway committed May 12, 2020 at 19:01 UTC 80c4dea0d1da0012977c6c4b2ac7a8bd37154d50
25 files changed +179 -61
packages/react-art/src/ReactARTHostConfig.js
+1 -1
@@ -473,7 +473,7 @@ export function getInstanceFromNode(node) {
473 throw new Error('Not yet implemented.');
474 }
475
476 -export function beforeRemoveInstance(instance) {
476 +export function removeInstanceEventHandles(instance) {
477 // noop
478 }
479
packages/react-dom/src/client/ReactDOMComponentTree.js
+15
@@ -9,6 +9,7 @@
9
10 import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
11 import type {ReactScopeInstance} from 'shared/ReactTypes';
12 +import type {ReactDOMEventHandleListener} from '../shared/ReactDOMTypes';
13 import type {
14 Container,
15 TextInstance,
@@ -37,6 +38,7 @@ const internalInstanceKey = '__reactFiber$' + randomKey;
38 const internalPropsKey = '__reactProps$' + randomKey;
39 const internalContainerInstanceKey = '__reactContainer$' + randomKey;
40 const internalEventHandlersKey = '__reactEvents$' + randomKey;
41 +const internalEventHandlerListenersKey = '__reactListeners$' + randomKey;
42
43 export type ElementListenerMap = Map<
44 DOMTopLevelEventType | string,
@@ -217,3 +219,16 @@ export function getFiberFromScopeInstance(
219 }
220 return null;
221 }
222 +
223 +export function setEventHandlerListeners(
224 + scope: EventTarget | ReactScopeInstance,
225 + listeners: Set<ReactDOMEventHandleListener>,
226 +): void {
227 + (scope: any)[internalEventHandlerListenersKey] = listeners;
228 +}
229 +
230 +export function getEventHandlerListeners(
231 + scope: EventTarget | ReactScopeInstance,
232 +): null | Set<ReactDOMEventHandleListener> {
233 + return (scope: any)[internalEventHandlerListenersKey] || null;
234 +}
packages/react-dom/src/client/ReactDOMHostConfig.js
+8 -7
@@ -77,6 +77,7 @@ import {
77 enableFundamentalAPI,
78 enableModernEventSystem,
79 enableScopeAPI,
80 + enableCreateEventHandleAPI,
81 } from 'shared/ReactFeatureFlags';
82 import {HostComponent, HostText} from 'react-reconciler/src/ReactWorkTags';
83 import {TOP_BEFORE_BLUR, TOP_AFTER_BLUR} from '../events/DOMTopLevelEventTypes';
@@ -233,7 +234,7 @@ export function prepareForCommit(containerInfo: Container): Object | null {
234 eventsEnabled = ReactBrowserEventEmitterIsEnabled();
235 selectionInformation = getSelectionInformation();
236 let activeInstance = null;
236 - if (enableDeprecatedFlareAPI) {
237 + if (enableDeprecatedFlareAPI || enableCreateEventHandleAPI) {
238 const focusedElem = selectionInformation.focusedElem;
239 if (focusedElem !== null) {
240 activeInstance = getClosestInstanceFromNode(focusedElem);
@@ -244,7 +245,7 @@ export function prepareForCommit(containerInfo: Container): Object | null {
245 }
246
247 export function beforeActiveInstanceBlur(): void {
247 - if (enableDeprecatedFlareAPI) {
248 + if (enableDeprecatedFlareAPI || enableCreateEventHandleAPI) {
249 ReactBrowserEventEmitterSetEnabled(true);
250 dispatchBeforeDetachedBlur((selectionInformation: any).focusedElem);
251 ReactBrowserEventEmitterSetEnabled(false);
@@ -252,7 +253,7 @@ export function beforeActiveInstanceBlur(): void {
253 }
254
255 export function afterActiveInstanceBlur(): void {
255 - if (enableDeprecatedFlareAPI) {
256 + if (enableDeprecatedFlareAPI || enableCreateEventHandleAPI) {
257 ReactBrowserEventEmitterSetEnabled(true);
258 dispatchAfterDetachedBlur((selectionInformation: any).focusedElem);
259 ReactBrowserEventEmitterSetEnabled(false);
@@ -515,7 +516,7 @@ function createEvent(type: TopLevelType): Event {
516 }
517
518 function dispatchBeforeDetachedBlur(target: HTMLElement): void {
518 - if (enableDeprecatedFlareAPI) {
519 + if (enableDeprecatedFlareAPI || enableCreateEventHandleAPI) {
520 const event = createEvent(TOP_BEFORE_BLUR);
521 // Dispatch "beforeblur" directly on the target,
522 // so it gets picked up by the event system and
@@ -525,7 +526,7 @@ function dispatchBeforeDetachedBlur(target: HTMLElement): void {
526 }
527
528 function dispatchAfterDetachedBlur(target: HTMLElement): void {
528 - if (enableDeprecatedFlareAPI) {
529 + if (enableDeprecatedFlareAPI || enableCreateEventHandleAPI) {
530 const event = createEvent(TOP_AFTER_BLUR);
531 // So we know what was detached, make the relatedTarget the
532 // detached target on the "afterblur" event.
@@ -535,7 +536,7 @@ function dispatchAfterDetachedBlur(target: HTMLElement): void {
536 }
537 }
538
538 -export function beforeRemoveInstance(
539 +export function removeInstanceEventHandles(
540 instance: Instance | TextInstance | SuspenseInstance,
541 ) {
542 // TODO for ReactDOM.createEventInstance
@@ -1135,7 +1136,7 @@ export function prepareScopeUpdate(
1136 }
1137 }
1138
1138 -export function prepareScopeUnmount(scopeInstance: Object): void {
1139 +export function removeScopeEventHandles(scopeInstance: Object): void {
1140 // TODO when we add createEventHandle
1141 }
1142
packages/react-dom/src/events/DOMEventProperties.js
+10 -1
@@ -24,6 +24,8 @@ import {
24 ContinuousEvent,
25 } from 'shared/ReactTypes';
26
27 +import {enableCreateEventHandleAPI} from 'shared/ReactFeatureFlags';
28 +
29 // Needed for SimpleEventPlugin, rather than
30 // do it in two places, which duplicates logic
31 // and increases the bundle size, we do it all
@@ -95,6 +97,13 @@ const otherDiscreteEvents = [
97 DOMTopLevelEventTypes.TOP_COMPOSITION_UPDATE,
98 ];
99
100 +if (enableCreateEventHandleAPI) {
101 + otherDiscreteEvents.push(
102 + DOMTopLevelEventTypes.TOP_BEFORE_BLUR,
103 + DOMTopLevelEventTypes.TOP_AFTER_BLUR,
104 + );
105 +}
106 +
107 // prettier-ignore
108 const userBlockingPairsForSimpleEventPlugin = [
109 DOMTopLevelEventTypes.TOP_DRAG, 'drag',
@@ -236,7 +245,7 @@ export function getEventPriorityForListenerSystem(
245 }
246 if (__DEV__) {
247 console.warn(
239 - 'The event "type" provided to useEvent() does not have a known priority type.' +
248 + 'The event "type" provided to createEventHandle() does not have a known priority type.' +
249 ' It is recommended to provide a "priority" option to specify a priority.',
250 );
251 }
packages/react-dom/src/events/DOMModernPluginEventSystem.js
+59 -24
@@ -32,7 +32,6 @@ import {
32 LEGACY_FB_SUPPORT,
33 IS_REPLAYED,
34 IS_TARGET_PHASE_ONLY,
35 - USE_EVENT_SYSTEM,
35 } from './EventSystemFlags';
36
37 import {
@@ -78,6 +77,8 @@ import {
77 TOP_PLAYING,
78 TOP_CLICK,
79 TOP_SELECTION_CHANGE,
80 + TOP_BEFORE_BLUR,
81 + TOP_AFTER_BLUR,
82 getRawEventName,
83 } from './DOMTopLevelEventTypes';
84 import {
@@ -89,7 +90,10 @@ import {batchedEventUpdates} from './ReactDOMUpdateBatching';
90 import getListener from './getListener';
91 import {passiveBrowserEventsSupported} from './checkPassiveEvents';
92
92 -import {enableLegacyFBSupport} from 'shared/ReactFeatureFlags';
93 +import {
94 + enableLegacyFBSupport,
95 + enableCreateEventHandleAPI,
96 +} from 'shared/ReactFeatureFlags';
97 import {
98 invokeGuardedCallbackAndCatchFirstError,
99 rethrowCaughtError,
@@ -99,9 +103,11 @@ import {
103 removeEventListener,
104 addEventCaptureListener,
105 addEventBubbleListener,
106 + addEventBubbleListenerWithPassiveFlag,
107 + addEventCaptureListenerWithPassiveFlag,
108 } from './EventListener';
109
104 -const capturePhaseEvents = new Set([
110 +export const capturePhaseEvents: Set<DOMTopLevelEventType> = new Set([
111 TOP_FOCUS,
112 TOP_BLUR,
113 TOP_SCROLL,
@@ -137,6 +143,11 @@ const capturePhaseEvents = new Set([
143 TOP_WAITING,
144 ]);
145
146 +if (enableCreateEventHandleAPI) {
147 + capturePhaseEvents.add(TOP_BEFORE_BLUR);
148 + capturePhaseEvents.add(TOP_AFTER_BLUR);
149 +}
150 +
151 function executeDispatch(
152 event: ReactSyntheticEvent,
153 listener: Function,
@@ -217,7 +228,7 @@ function dispatchEventsForPlugins(
228
229 export function listenToTopLevelEvent(
230 topLevelType: DOMTopLevelEventType,
220 - targetContainer: EventTarget,
231 + target: EventTarget,
232 listenerMap: ElementListenerMap,
233 eventSystemFlags: EventSystemFlags,
234 passive?: boolean,
@@ -228,25 +239,26 @@ export function listenToTopLevelEvent(
239 // otherwise it won't capture incoming events that are only
240 // triggered on the document directly.
241 if (topLevelType === TOP_SELECTION_CHANGE) {
231 - targetContainer = (targetContainer: any).ownerDocument || targetContainer;
232 - listenerMap = getEventListenerMap(targetContainer);
242 + target = (target: any).ownerDocument || target;
243 + listenerMap = getEventListenerMap(target);
244 }
245 + capture =
246 + capture === undefined ? capturePhaseEvents.has(topLevelType) : capture;
247 + const listenerMapKey = getListenerMapKey(topLevelType, capture);
248 const listenerEntry: ElementListenerMapEntry | void = listenerMap.get(
235 - topLevelType,
249 + listenerMapKey,
250 );
237 - const isCapturePhase =
238 - capture === undefined ? capturePhaseEvents.has(topLevelType) : capture;
251 if (listenerEntry === undefined) {
252 const listener = addTrappedEventListener(
241 - targetContainer,
253 + target,
254 topLevelType,
255 eventSystemFlags,
244 - isCapturePhase,
256 + capture,
257 false,
258 passive,
259 priority,
260 );
249 - listenerMap.set(topLevelType, {passive, listener});
261 + listenerMap.set(listenerMapKey, {passive, listener});
262 }
263 }
264
@@ -324,17 +336,35 @@ function addTrappedEventListener(
336 };
337 }
338 if (capture) {
327 - unsubscribeListener = addEventCaptureListener(
328 - targetContainer,
329 - rawEventName,
330 - listener,
331 - );
339 + if (enableCreateEventHandleAPI && passive !== undefined) {
340 + unsubscribeListener = addEventCaptureListenerWithPassiveFlag(
341 + targetContainer,
342 + rawEventName,
343 + listener,
344 + passive,
345 + );
346 + } else {
347 + unsubscribeListener = addEventCaptureListener(
348 + targetContainer,
349 + rawEventName,
350 + listener,
351 + );
352 + }
353 } else {
333 - unsubscribeListener = addEventBubbleListener(
334 - targetContainer,
335 - rawEventName,
336 - listener,
337 - );
354 + if (enableCreateEventHandleAPI && passive !== undefined) {
355 + unsubscribeListener = addEventBubbleListenerWithPassiveFlag(
356 + targetContainer,
357 + rawEventName,
358 + listener,
359 + passive,
360 + );
361 + } else {
362 + unsubscribeListener = addEventBubbleListener(
363 + targetContainer,
364 + rawEventName,
365 + listener,
366 + );
367 + }
368 }
369 return unsubscribeListener;
370 }
@@ -397,8 +427,6 @@ export function dispatchEventForPluginEventSystem(
427 (eventSystemFlags & LEGACY_FB_SUPPORT) === 0 &&
428 // We also don't want to defer during event replaying.
429 (eventSystemFlags & IS_REPLAYED) === 0 &&
400 - // We don't want to apply the legacy FB support for the useEvent API.
401 - (eventSystemFlags & USE_EVENT_SYSTEM) === 0 &&
430 willDeferLaterForLegacyFBSupport(topLevelType, targetContainer)
431 ) {
432 return;
@@ -707,3 +735,10 @@ export function accumulateEnterLeaveListeners(
735 );
736 }
737 }
738 +
739 +export function getListenerMapKey(
740 + topLevelType: DOMTopLevelEventType,
741 + capture: boolean,
742 +): string {
743 + return `${getRawEventName(topLevelType)}__${capture ? 'capture' : 'bubble'}`;
744 +}
packages/react-dom/src/events/EventSystemFlags.js
+6 -7
@@ -11,10 +11,9 @@ export type EventSystemFlags = number;
11
12 export const PLUGIN_EVENT_SYSTEM = 1;
13 export const RESPONDER_EVENT_SYSTEM = 1 << 1;
14 -export const USE_EVENT_SYSTEM = 1 << 2;
15 -export const IS_TARGET_PHASE_ONLY = 1 << 3;
16 -export const IS_PASSIVE = 1 << 4;
17 -export const PASSIVE_NOT_SUPPORTED = 1 << 5;
18 -export const IS_REPLAYED = 1 << 6;
19 -export const IS_FIRST_ANCESTOR = 1 << 7;
20 -export const LEGACY_FB_SUPPORT = 1 << 8;
14 +export const IS_TARGET_PHASE_ONLY = 1 << 2;
15 +export const IS_PASSIVE = 1 << 3;
16 +export const PASSIVE_NOT_SUPPORTED = 1 << 4;
17 +export const IS_REPLAYED = 1 << 5;
18 +export const IS_FIRST_ANCESTOR = 1 << 6;
19 +export const LEGACY_FB_SUPPORT = 1 << 7;
packages/react-dom/src/events/plugins/ModernSelectEventPlugin.js
+11 -3
@@ -28,7 +28,11 @@ import {
28 } from '../../client/ReactDOMComponentTree';
29 import {hasSelectionCapabilities} from '../../client/ReactInputSelection';
30 import {DOCUMENT_NODE} from '../../shared/HTMLNodeType';
31 -import {accumulateTwoPhaseListeners} from '../DOMModernPluginEventSystem';
31 +import {
32 + accumulateTwoPhaseListeners,
33 + getListenerMapKey,
34 + capturePhaseEvents,
35 +} from '../DOMModernPluginEventSystem';
36
37 const skipSelectionChangeEvent =
38 canUseDOM && 'documentMode' in document && document.documentMode <= 11;
@@ -153,7 +157,9 @@ function isListeningToEvents(
157 const listenerMap = getEventListenerMap(mountAt);
158 for (let i = 0; i < events.length; i++) {
159 const event = events[i];
156 - if (!listenerMap.has(event)) {
160 + const capture = capturePhaseEvents.has(event);
161 + const listenerMapKey = getListenerMapKey(event, capture);
162 + if (!listenerMap.has(listenerMapKey)) {
163 return false;
164 }
165 }
@@ -165,7 +171,9 @@ function isListeningToEvent(
171 mountAt: Document | Element,
172 ): boolean {
173 const listenerMap = getEventListenerMap(mountAt);
168 - return listenerMap.has(registrationName);
174 + const capture = capturePhaseEvents.has(registrationName);
175 + const listenerMapKey = getListenerMapKey(registrationName, capture);
176 + return listenerMap.has(listenerMapKey);
177 }
178
179 /**
packages/react-dom/src/events/plugins/ModernSimpleEventPlugin.js
+13 -1
@@ -26,6 +26,7 @@ import {
26 simpleEventPluginEventTypes,
27 } from '../DOMEventProperties';
28 import {accumulateTwoPhaseListeners} from '../DOMModernPluginEventSystem';
29 +import {IS_TARGET_PHASE_ONLY} from '../EventSystemFlags';
30
31 import SyntheticAnimationEvent from '../SyntheticAnimationEvent';
32 import SyntheticClipboardEvent from '../SyntheticClipboardEvent';
@@ -40,6 +41,8 @@ import SyntheticUIEvent from '../SyntheticUIEvent';
41 import SyntheticWheelEvent from '../SyntheticWheelEvent';
42 import getEventCharCode from '../getEventCharCode';
43
44 +import {enableCreateEventHandleAPI} from 'shared/ReactFeatureFlags';
45 +
46 // Only used in DEV for exhaustiveness validation.
47 const knownHTMLTopLevelTypes: Array<DOMTopLevelEventType> = [
48 DOMTopLevelEventTypes.TOP_ABORT,
@@ -201,7 +204,16 @@ const SimpleEventPlugin: ModernPluginModule<MouseEvent> = {
204 nativeEventTarget,
205 );
206
204 - accumulateTwoPhaseListeners(targetInst, dispatchQueue, event);
207 + if (
208 + enableCreateEventHandleAPI &&
209 + eventSystemFlags !== undefined &&
210 + eventSystemFlags & IS_TARGET_PHASE_ONLY &&
211 + targetContainer != null
212 + ) {
213 + // TODO: accumulateEventTargetListeners
214 + } else {
215 + accumulateTwoPhaseListeners(targetInst, dispatchQueue, event);
216 + }
217 },
218 };
219
packages/react-dom/src/shared/ReactDOMTypes.js
+17
@@ -12,7 +12,9 @@ import type {
12 ReactEventResponder,
13 ReactEventResponderInstance,
14 EventPriority,
15 + ReactScopeInstance,
16 } from 'shared/ReactTypes';
17 +import type {DOMTopLevelEventType} from 'legacy-events/TopLevelEventTypes';
18
19 type AnyNativeEvent = Event | KeyboardEvent | MouseEvent | Touch;
20
@@ -75,3 +77,18 @@ export type ReactDOMResponderContext = {
77 getResponderNode(): Element | null,
78 ...
79 };
80 +
81 +export type ReactDOMEventHandle = {|
82 + setListener(
83 + target: EventTarget | ReactScopeInstance,
84 + callback: (SyntheticEvent<EventTarget>) => void,
85 + ): void,
86 + clear(): void,
87 +|};
88 +
89 +export type ReactDOMEventHandleListener = {|
90 + callback: (SyntheticEvent<EventTarget>) => void,
91 + capture: boolean,
92 + destroy: (target: EventTarget | ReactScopeInstance) => void,
93 + type: DOMTopLevelEventType,
94 +|};
packages/react-native-renderer/src/ReactFabricHostConfig.js
+1 -1
@@ -483,7 +483,7 @@ export function getInstanceFromNode(node: any) {
483 throw new Error('Not yet implemented.');
484 }
485
486 -export function beforeRemoveInstance(instance: any) {
486 +export function removeInstanceEventHandles(instance: any) {
487 // noop
488 }
489
packages/react-native-renderer/src/ReactNativeHostConfig.js
+1 -1
@@ -536,7 +536,7 @@ export function getInstanceFromNode(node: any) {
536 throw new Error('Not yet implemented.');
537 }
538
539 -export function beforeRemoveInstance(instance: any) {
539 +export function removeInstanceEventHandles(instance: any) {
540 // noop
541 }
542
packages/react-noop-renderer/src/createReactNoop.js
+2 -2
@@ -442,7 +442,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
442 throw new Error('Not yet implemented.');
443 },
444
445 - beforeRemoveInstance(instance: any): void {
445 + removeInstanceEventHandles(instance: any): void {
446 // NO-OP
447 },
448
@@ -460,7 +460,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
460
461 prepareScopeUpdate() {},
462
463 - prepareScopeUnmount() {},
463 + removeScopeEventHandles() {},
464
465 getInstanceFromScope() {
466 throw new Error('Not yet implemented.');
packages/react-reconciler/src/ReactFiberCommitWork.new.js
+9 -4
@@ -37,6 +37,7 @@ import {
37 enableSuspenseCallback,
38 enableScopeAPI,
39 runAllPassiveEffectDestroysBeforeCreates,
40 + enableCreateEventHandleAPI,
41 } from 'shared/ReactFeatureFlags';
42 import {
43 FunctionComponent,
@@ -113,10 +114,10 @@ import {
114 updateFundamentalComponent,
115 commitHydratedContainer,
116 commitHydratedSuspenseInstance,
116 - beforeRemoveInstance,
117 + removeInstanceEventHandles,
118 clearContainer,
119 prepareScopeUpdate,
119 - prepareScopeUnmount,
120 + removeScopeEventHandles,
121 } from './ReactFiberHostConfig';
122 import {
123 captureCommitPhaseError,
@@ -1029,7 +1030,9 @@ function commitUnmount(
1030 if (enableDeprecatedFlareAPI) {
1031 unmountDeprecatedResponderListeners(current);
1032 }
1032 - beforeRemoveInstance(current.stateNode);
1033 + if (enableCreateEventHandleAPI && current.ref !== null) {
1034 + removeInstanceEventHandles(current.stateNode);
1035 + }
1036 safelyDetachRef(current);
1037 return;
1038 }
@@ -1072,7 +1075,9 @@ function commitUnmount(
1075 unmountDeprecatedResponderListeners(current);
1076 }
1077 const scopeInstance = current.stateNode;
1075 - prepareScopeUnmount(scopeInstance);
1078 + if (enableCreateEventHandleAPI && current.ref !== null) {
1079 + removeScopeEventHandles(scopeInstance);
1080 + }
1081 safelyDetachRef(current);
1082 }
1083 return;
packages/react-reconciler/src/ReactFiberCommitWork.old.js
+9 -4
@@ -36,6 +36,7 @@ import {
36 enableSuspenseCallback,
37 enableScopeAPI,
38 runAllPassiveEffectDestroysBeforeCreates,
39 + enableCreateEventHandleAPI,
40 } from 'shared/ReactFeatureFlags';
41 import {
42 FunctionComponent,
@@ -110,10 +111,10 @@ import {
111 updateFundamentalComponent,
112 commitHydratedContainer,
113 commitHydratedSuspenseInstance,
113 - beforeRemoveInstance,
114 + removeInstanceEventHandles,
115 clearContainer,
116 prepareScopeUpdate,
116 - prepareScopeUnmount,
117 + removeScopeEventHandles,
118 } from './ReactFiberHostConfig';
119 import {
120 captureCommitPhaseError,
@@ -1027,7 +1028,9 @@ function commitUnmount(
1028 if (enableDeprecatedFlareAPI) {
1029 unmountDeprecatedResponderListeners(current);
1030 }
1030 - beforeRemoveInstance(current.stateNode);
1031 + if (enableCreateEventHandleAPI && current.ref !== null) {
1032 + removeInstanceEventHandles(current.stateNode);
1033 + }
1034 safelyDetachRef(current);
1035 return;
1036 }
@@ -1070,7 +1073,9 @@ function commitUnmount(
1073 unmountDeprecatedResponderListeners(current);
1074 }
1075 const scopeInstance = current.stateNode;
1073 - prepareScopeUnmount(scopeInstance);
1076 + if (enableCreateEventHandleAPI && current.ref !== null) {
1077 + removeScopeEventHandles(scopeInstance);
1078 + }
1079 safelyDetachRef(current);
1080 }
1081 return;
packages/react-reconciler/src/ReactFiberHostConfigWithNoScopes.js
+1 -1
@@ -23,5 +23,5 @@ function shim(...args: any) {
23
24 // React Scopes (when unsupported)
25 export const prepareScopeUpdate = shim;
26 -export const prepareScopeUnmount = shim;
26 +export const removeScopeEventHandles = shim;
27 export const getInstanceFromScope = shim;
packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js
+3 -2
@@ -74,7 +74,8 @@ export const mountFundamentalComponent =
74 export const shouldUpdateFundamentalComponent =
75 $$$hostConfig.shouldUpdateFundamentalComponent;
76 export const getInstanceFromNode = $$$hostConfig.getInstanceFromNode;
77 -export const beforeRemoveInstance = $$$hostConfig.beforeRemoveInstance;
77 +export const removeInstanceEventHandles =
78 + $$$hostConfig.removeInstanceEventHandles;
79 export const isOpaqueHydratingObject = $$$hostConfig.isOpaqueHydratingObject;
80 export const makeOpaqueHydratingObject =
81 $$$hostConfig.makeOpaqueHydratingObject;
@@ -84,7 +85,7 @@ export const beforeActiveInstanceBlur = $$$hostConfig.beforeActiveInstanceBlur;
85 export const afterActiveInstanceBlur = $$$hostConfig.afterActiveInstanceBlur;
86 export const preparePortalMount = $$$hostConfig.preparePortalMount;
87 export const prepareScopeUpdate = $$$hostConfig.preparePortalMount;
87 -export const prepareScopeUnmount = $$$hostConfig.prepareScopeUnmount;
88 +export const removeScopeEventHandles = $$$hostConfig.removeScopeEventHandles;
89 export const getInstanceFromScope = $$$hostConfig.getInstanceFromScope;
90
91 // -------------------
packages/react-test-renderer/src/ReactTestHostConfig.js
+2 -2
@@ -387,7 +387,7 @@ export function getInstanceFromNode(mockNode: Object) {
387 return null;
388 }
389
390 -export function beforeRemoveInstance(instance: any) {
390 +export function removeInstanceEventHandles(instance: any) {
391 // noop
392 }
393
@@ -444,7 +444,7 @@ export function prepareScopeUpdate(scopeInstance: Object, inst: Object): void {
444 nodeToInstanceMap.set(scopeInstance, inst);
445 }
446
447 -export function prepareScopeUnmount(scopeInstance: Object): void {
447 +export function removeScopeEventHandles(scopeInstance: Object): void {
448 nodeToInstanceMap.delete(scopeInstance);
449 }
450
packages/shared/ReactFeatureFlags.js
+3
@@ -57,6 +57,9 @@ export const enableFundamentalAPI = false;
57 // Experimental Scope support.
58 export const enableScopeAPI = false;
59
60 +// Experimental Create Event Handle API.
61 +export const enableCreateEventHandleAPI = false;
62 +
63 // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
64
65 // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
packages/shared/forks/ReactFeatureFlags.native-fb.js
+1
@@ -27,6 +27,7 @@ export const warnAboutDeprecatedLifecycles = true;
27 export const enableDeprecatedFlareAPI = false;
28 export const enableFundamentalAPI = false;
29 export const enableScopeAPI = false;
30 +export const enableCreateEventHandleAPI = false;
31 export const warnAboutUnmockedScheduler = true;
32 export const enableSuspenseCallback = false;
33 export const warnAboutDefaultPropsOnFunctionComponents = false;
packages/shared/forks/ReactFeatureFlags.native-oss.js
+1
@@ -26,6 +26,7 @@ export const enableSchedulerDebugging = false;
26 export const enableDeprecatedFlareAPI = false;
27 export const enableFundamentalAPI = false;
28 export const enableScopeAPI = false;
29 +export const enableCreateEventHandleAPI = false;
30 export const warnAboutUnmockedScheduler = false;
31 export const enableSuspenseCallback = false;
32 export const warnAboutDefaultPropsOnFunctionComponents = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
+1
@@ -26,6 +26,7 @@ export const enableSchedulerDebugging = false;
26 export const enableDeprecatedFlareAPI = false;
27 export const enableFundamentalAPI = false;
28 export const enableScopeAPI = false;
29 +export const enableCreateEventHandleAPI = false;
30 export const warnAboutUnmockedScheduler = false;
31 export const enableSuspenseCallback = false;
32 export const warnAboutDefaultPropsOnFunctionComponents = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+1
@@ -26,6 +26,7 @@ export const disableInputAttributeSyncing = false;
26 export const enableDeprecatedFlareAPI = true;
27 export const enableFundamentalAPI = false;
28 export const enableScopeAPI = true;
29 +export const enableCreateEventHandleAPI = false;
30 export const warnAboutUnmockedScheduler = true;
31 export const enableSuspenseCallback = true;
32 export const warnAboutDefaultPropsOnFunctionComponents = false;
packages/shared/forks/ReactFeatureFlags.testing.js
+1
@@ -26,6 +26,7 @@ export const enableSchedulerDebugging = false;
26 export const enableDeprecatedFlareAPI = false;
27 export const enableFundamentalAPI = false;
28 export const enableScopeAPI = false;
29 +export const enableCreateEventHandleAPI = false;
30 export const warnAboutUnmockedScheduler = false;
31 export const enableSuspenseCallback = false;
32 export const warnAboutDefaultPropsOnFunctionComponents = false;
packages/shared/forks/ReactFeatureFlags.testing.www.js
+1
@@ -26,6 +26,7 @@ export const enableSchedulerDebugging = false;
26 export const enableDeprecatedFlareAPI = true;
27 export const enableFundamentalAPI = false;
28 export const enableScopeAPI = true;
29 +export const enableCreateEventHandleAPI = false;
30 export const warnAboutUnmockedScheduler = true;
31 export const enableSuspenseCallback = true;
32 export const warnAboutDefaultPropsOnFunctionComponents = false;
packages/shared/forks/ReactFeatureFlags.www.js
+2
@@ -58,6 +58,8 @@ export const disableModulePatternComponents = true;
58
59 export const enableDeprecatedFlareAPI = true;
60
61 +export const enableCreateEventHandleAPI = false;
62 +
63 export const enableFundamentalAPI = false;
64
65 export const enableScopeAPI = true;