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

Function extractCompositionEvent

code/composition/public/app.js:3420–3465  ·  view source on GitHub ↗

* @return {?object} A SyntheticCompositionEvent.

(topLevelType, targetInst, nativeEvent, nativeEventTarget)

Source from the content-addressed store, hash-verified

3418 * @return {?object} A SyntheticCompositionEvent.
3419 */
3420function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
3421 var eventType = void 0;
3422 var fallbackData = void 0;
3423
3424 if (canUseCompositionEvent) {
3425 eventType = getCompositionEventType(topLevelType);
3426 } else if (!isComposing) {
3427 if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
3428 eventType = eventTypes.compositionStart;
3429 }
3430 } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
3431 eventType = eventTypes.compositionEnd;
3432 }
3433
3434 if (!eventType) {
3435 return null;
3436 }
3437
3438 if (useFallbackCompositionData) {
3439 // The current composition is stored statically and must not be
3440 // overwritten while composition continues.
3441 if (!isComposing && eventType === eventTypes.compositionStart) {
3442 isComposing = initialize(nativeEventTarget);
3443 } else if (eventType === eventTypes.compositionEnd) {
3444 if (isComposing) {
3445 fallbackData = getData();
3446 }
3447 }
3448 }
3449
3450 var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget);
3451
3452 if (fallbackData) {
3453 // Inject data generated from fallback path into the synthetic event.
3454 // This matches the property of native CompositionEventInterface.
3455 event.data = fallbackData;
3456 } else {
3457 var customData = getDataFromCustomEvent(nativeEvent);
3458 if (customData !== null) {
3459 event.data = customData;
3460 }
3461 }
3462
3463 accumulateTwoPhaseDispatches(event);
3464 return event;
3465}
3466
3467/**
3468 * @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