MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / extractCompositionEvent

Function extractCompositionEvent

code/third-party/public/app.js:2515–2560  ·  view source on GitHub ↗

* @return {?object} A SyntheticCompositionEvent.

(topLevelType, targetInst, nativeEvent, nativeEventTarget)

Source from the content-addressed store, hash-verified

2513 * @return {?object} A SyntheticCompositionEvent.
2514 */
2515function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
2516 var eventType = void 0;
2517 var fallbackData = void 0;
2518
2519 if (canUseCompositionEvent) {
2520 eventType = getCompositionEventType(topLevelType);
2521 } else if (!isComposing) {
2522 if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
2523 eventType = eventTypes.compositionStart;
2524 }
2525 } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
2526 eventType = eventTypes.compositionEnd;
2527 }
2528
2529 if (!eventType) {
2530 return null;
2531 }
2532
2533 if (useFallbackCompositionData) {
2534 // The current composition is stored statically and must not be
2535 // overwritten while composition continues.
2536 if (!isComposing && eventType === eventTypes.compositionStart) {
2537 isComposing = initialize(nativeEventTarget);
2538 } else if (eventType === eventTypes.compositionEnd) {
2539 if (isComposing) {
2540 fallbackData = getData();
2541 }
2542 }
2543 }
2544
2545 var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget);
2546
2547 if (fallbackData) {
2548 // Inject data generated from fallback path into the synthetic event.
2549 // This matches the property of native CompositionEventInterface.
2550 event.data = fallbackData;
2551 } else {
2552 var customData = getDataFromCustomEvent(nativeEvent);
2553 if (customData !== null) {
2554 event.data = customData;
2555 }
2556 }
2557
2558 accumulateTwoPhaseDispatches(event);
2559 return event;
2560}
2561
2562/**
2563 * @param {TopLevelTypes} topLevelType Record from `BrowserEventConstants`.

Callers 1

app.jsFile · 0.70

Calls 7

getCompositionEventTypeFunction · 0.70
isFallbackCompositionEndFunction · 0.70
initializeFunction · 0.70
getDataFunction · 0.70
getDataFromCustomEventFunction · 0.70

Tested by

no test coverage detected