* @return {?object} A SyntheticCompositionEvent.
(topLevelType, targetInst, nativeEvent, nativeEventTarget)
| 3280 | * @return {?object} A SyntheticCompositionEvent. |
| 3281 | */ |
| 3282 | function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { |
| 3283 | var eventType = void 0; |
| 3284 | var fallbackData = void 0; |
| 3285 | |
| 3286 | if (canUseCompositionEvent) { |
| 3287 | eventType = getCompositionEventType(topLevelType); |
| 3288 | } else if (!isComposing) { |
| 3289 | if (isFallbackCompositionStart(topLevelType, nativeEvent)) { |
| 3290 | eventType = eventTypes.compositionStart; |
| 3291 | } |
| 3292 | } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { |
| 3293 | eventType = eventTypes.compositionEnd; |
| 3294 | } |
| 3295 | |
| 3296 | if (!eventType) { |
| 3297 | return null; |
| 3298 | } |
| 3299 | |
| 3300 | if (useFallbackCompositionData) { |
| 3301 | // The current composition is stored statically and must not be |
| 3302 | // overwritten while composition continues. |
| 3303 | if (!isComposing && eventType === eventTypes.compositionStart) { |
| 3304 | isComposing = initialize(nativeEventTarget); |
| 3305 | } else if (eventType === eventTypes.compositionEnd) { |
| 3306 | if (isComposing) { |
| 3307 | fallbackData = getData(); |
| 3308 | } |
| 3309 | } |
| 3310 | } |
| 3311 | |
| 3312 | var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget); |
| 3313 | |
| 3314 | if (fallbackData) { |
| 3315 | // Inject data generated from fallback path into the synthetic event. |
| 3316 | // This matches the property of native CompositionEventInterface. |
| 3317 | event.data = fallbackData; |
| 3318 | } else { |
| 3319 | var customData = getDataFromCustomEvent(nativeEvent); |
| 3320 | if (customData !== null) { |
| 3321 | event.data = customData; |
| 3322 | } |
| 3323 | } |
| 3324 | |
| 3325 | accumulateTwoPhaseDispatches(event); |
| 3326 | return event; |
| 3327 | } |
| 3328 | |
| 3329 | /** |
| 3330 | * @param {TopLevelTypes} topLevelType Record from `BrowserEventConstants`. |
no test coverage detected