function extractBeforeInputEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
  var chars;

  if (canUseTextInputEvent) {
    chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
  } else {
    chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
  }

  // If no characters are being inserted, no BeforeInput event should
  // be fired.
  if (!chars) {
    return null;
  }

  var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, topLevelTargetID, nativeEvent, nativeEventTarget);

  event.data = chars;
  EventPropagators.accumulateTwoPhaseDispatches(event);
  return event;
}
Extract a SyntheticInputEvent for `beforeInput`, based on either native
`textInput` or fallback behavior.

@param {string} topLevelType Record from `EventConstants`.
@param {DOMEventTarget} topLevelTarget The listening component root node.
@param {string} topLevelTargetID ID of `topLevelTarget`.
@param {object} nativeEvent Native browser event.
@return {?object} A SyntheticInputEvent.