* @return {?object} A SyntheticCompositionEvent.
(topLevelType, targetInst, nativeEvent, nativeEventTarget)
| 3315 | * @return {?object} A SyntheticCompositionEvent. |
| 3316 | */ |
| 3317 | function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { |
| 3318 | var eventType = void 0; |
| 3319 | var fallbackData = void 0; |
| 3320 | |
| 3321 | if (canUseCompositionEvent) { |
| 3322 | eventType = getCompositionEventType(topLevelType); |
| 3323 | } else if (!isComposing) { |
| 3324 | if (isFallbackCompositionStart(topLevelType, nativeEvent)) { |
| 3325 | eventType = eventTypes.compositionStart; |
| 3326 | } |
| 3327 | } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { |
| 3328 | eventType = eventTypes.compositionEnd; |
| 3329 | } |
| 3330 | |
| 3331 | if (!eventType) { |
| 3332 | return null; |
| 3333 | } |
| 3334 | |
| 3335 | if (useFallbackCompositionData) { |
| 3336 | // The current composition is stored statically and must not be |
| 3337 | // overwritten while composition continues. |
| 3338 | if (!isComposing && eventType === eventTypes.compositionStart) { |
| 3339 | isComposing = initialize(nativeEventTarget); |
| 3340 | } else if (eventType === eventTypes.compositionEnd) { |
| 3341 | if (isComposing) { |
| 3342 | fallbackData = getData(); |
| 3343 | } |
| 3344 | } |
| 3345 | } |
| 3346 | |
| 3347 | var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget); |
| 3348 | |
| 3349 | if (fallbackData) { |
| 3350 | // Inject data generated from fallback path into the synthetic event. |
| 3351 | // This matches the property of native CompositionEventInterface. |
| 3352 | event.data = fallbackData; |
| 3353 | } else { |
| 3354 | var customData = getDataFromCustomEvent(nativeEvent); |
| 3355 | if (customData !== null) { |
| 3356 | event.data = customData; |
| 3357 | } |
| 3358 | } |
| 3359 | |
| 3360 | accumulateTwoPhaseDispatches(event); |
| 3361 | return event; |
| 3362 | } |
| 3363 | |
| 3364 | /** |
| 3365 | * @param {TopLevelTypes} topLevelType Record from `BrowserEventConstants`. |
no test coverage detected