MCPcopy Create free account
hub / github.com/Lobos/react-ui / extractCompositionEvent

Function extractCompositionEvent

docs/lib/react.js:210–255  ·  view source on GitHub ↗

* @return {?object} A SyntheticCompositionEvent.

(topLevelType, targetInst, nativeEvent, nativeEventTarget)

Source from the content-addressed store, hash-verified

208 * @return {?object} A SyntheticCompositionEvent.
209 */
210function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
211 var eventType;
212 var fallbackData;
213
214 if (canUseCompositionEvent) {
215 eventType = getCompositionEventType(topLevelType);
216 } else if (!currentComposition) {
217 if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
218 eventType = eventTypes.compositionStart;
219 }
220 } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
221 eventType = eventTypes.compositionEnd;
222 }
223
224 if (!eventType) {
225 return null;
226 }
227
228 if (useFallbackCompositionData) {
229 // The current composition is stored statically and must not be
230 // overwritten while composition continues.
231 if (!currentComposition && eventType === eventTypes.compositionStart) {
232 currentComposition = FallbackCompositionState.getPooled(nativeEventTarget);
233 } else if (eventType === eventTypes.compositionEnd) {
234 if (currentComposition) {
235 fallbackData = currentComposition.getData();
236 }
237 }
238 }
239
240 var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget);
241
242 if (fallbackData) {
243 // Inject data generated from fallback path into the synthetic event.
244 // This matches the property of native CompositionEventInterface.
245 event.data = fallbackData;
246 } else {
247 var customData = getDataFromCustomEvent(nativeEvent);
248 if (customData !== null) {
249 event.data = customData;
250 }
251 }
252
253 EventPropagators.accumulateTwoPhaseDispatches(event);
254 return event;
255}
256
257/**
258 * @param {string} topLevelType Record from `EventConstants`.

Callers 1

react.jsFile · 0.85

Calls 5

getCompositionEventTypeFunction · 0.85
isFallbackCompositionEndFunction · 0.85
getDataFromCustomEventFunction · 0.85
getDataMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…