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

Function extractCompositionEvent

code/redux/public/app.js:3533–3578  ·  view source on GitHub ↗

* @return {?object} A SyntheticCompositionEvent.

(topLevelType, targetInst, nativeEvent, nativeEventTarget)

Source from the content-addressed store, hash-verified

3531 * @return {?object} A SyntheticCompositionEvent.
3532 */
3533function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
3534 var eventType = void 0;
3535 var fallbackData = void 0;
3536
3537 if (canUseCompositionEvent) {
3538 eventType = getCompositionEventType(topLevelType);
3539 } else if (!isComposing) {
3540 if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
3541 eventType = eventTypes.compositionStart;
3542 }
3543 } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
3544 eventType = eventTypes.compositionEnd;
3545 }
3546
3547 if (!eventType) {
3548 return null;
3549 }
3550
3551 if (useFallbackCompositionData) {
3552 // The current composition is stored statically and must not be
3553 // overwritten while composition continues.
3554 if (!isComposing && eventType === eventTypes.compositionStart) {
3555 isComposing = initialize(nativeEventTarget);
3556 } else if (eventType === eventTypes.compositionEnd) {
3557 if (isComposing) {
3558 fallbackData = getData();
3559 }
3560 }
3561 }
3562
3563 var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget);
3564
3565 if (fallbackData) {
3566 // Inject data generated from fallback path into the synthetic event.
3567 // This matches the property of native CompositionEventInterface.
3568 event.data = fallbackData;
3569 } else {
3570 var customData = getDataFromCustomEvent(nativeEvent);
3571 if (customData !== null) {
3572 event.data = customData;
3573 }
3574 }
3575
3576 accumulateTwoPhaseDispatches(event);
3577 return event;
3578}
3579
3580/**
3581 * @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