MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / extractCompositionEvent

Function extractCompositionEvent

code/new-context-api/public/app.js:2643–2688  ·  view source on GitHub ↗

* @return {?object} A SyntheticCompositionEvent.

(topLevelType, targetInst, nativeEvent, nativeEventTarget)

Source from the content-addressed store, hash-verified

2641 * @return {?object} A SyntheticCompositionEvent.
2642 */
2643function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
2644 var eventType = void 0;
2645 var fallbackData = void 0;
2646
2647 if (canUseCompositionEvent) {
2648 eventType = getCompositionEventType(topLevelType);
2649 } else if (!isComposing) {
2650 if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
2651 eventType = eventTypes.compositionStart;
2652 }
2653 } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
2654 eventType = eventTypes.compositionEnd;
2655 }
2656
2657 if (!eventType) {
2658 return null;
2659 }
2660
2661 if (useFallbackCompositionData) {
2662 // The current composition is stored statically and must not be
2663 // overwritten while composition continues.
2664 if (!isComposing && eventType === eventTypes.compositionStart) {
2665 isComposing = initialize(nativeEventTarget);
2666 } else if (eventType === eventTypes.compositionEnd) {
2667 if (isComposing) {
2668 fallbackData = getData();
2669 }
2670 }
2671 }
2672
2673 var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget);
2674
2675 if (fallbackData) {
2676 // Inject data generated from fallback path into the synthetic event.
2677 // This matches the property of native CompositionEventInterface.
2678 event.data = fallbackData;
2679 } else {
2680 var customData = getDataFromCustomEvent(nativeEvent);
2681 if (customData !== null) {
2682 event.data = customData;
2683 }
2684 }
2685
2686 accumulateTwoPhaseDispatches(event);
2687 return event;
2688}
2689
2690/**
2691 * @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