* @return {?object} A SyntheticCompositionEvent.
(topLevelType, targetInst, nativeEvent, nativeEventTarget)
| 8913 | */ |
| 8914 | |
| 8915 | function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { |
| 8916 | var eventType; |
| 8917 | var fallbackData; |
| 8918 | |
| 8919 | if (canUseCompositionEvent) { |
| 8920 | eventType = getCompositionEventType(topLevelType); |
| 8921 | } else if (!isComposing) { |
| 8922 | if (isFallbackCompositionStart(topLevelType, nativeEvent)) { |
| 8923 | eventType = eventTypes.compositionStart; |
| 8924 | } |
| 8925 | } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { |
| 8926 | eventType = eventTypes.compositionEnd; |
| 8927 | } |
| 8928 | |
| 8929 | if (!eventType) { |
| 8930 | return null; |
| 8931 | } |
| 8932 | |
| 8933 | if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) { |
| 8934 | // The current composition is stored statically and must not be |
| 8935 | // overwritten while composition continues. |
| 8936 | if (!isComposing && eventType === eventTypes.compositionStart) { |
| 8937 | isComposing = initialize(nativeEventTarget); |
| 8938 | } else if (eventType === eventTypes.compositionEnd) { |
| 8939 | if (isComposing) { |
| 8940 | fallbackData = getData(); |
| 8941 | } |
| 8942 | } |
| 8943 | } |
| 8944 | |
| 8945 | var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget); |
| 8946 | |
| 8947 | if (fallbackData) { |
| 8948 | // Inject data generated from fallback path into the synthetic event. |
| 8949 | // This matches the property of native CompositionEventInterface. |
| 8950 | event.data = fallbackData; |
| 8951 | } else { |
| 8952 | var customData = getDataFromCustomEvent(nativeEvent); |
| 8953 | |
| 8954 | if (customData !== null) { |
| 8955 | event.data = customData; |
| 8956 | } |
| 8957 | } |
| 8958 | |
| 8959 | accumulateTwoPhaseDispatches(event); |
| 8960 | return event; |
| 8961 | } |
| 8962 | /** |
| 8963 | * @param {TopLevelType} topLevelType Number from `TopLevelType`. |
| 8964 | * @param {object} nativeEvent Native browser event. |
no test coverage detected