(topLevelType, eventSystemFlags, container, nativeEvent)
| 7910 | } // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked. |
| 7911 | |
| 7912 | function attemptToDispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent) { |
| 7913 | // TODO: Warn if _enabled is false. |
| 7914 | var nativeEventTarget = getEventTarget(nativeEvent); |
| 7915 | var targetInst = getClosestInstanceFromNode(nativeEventTarget); |
| 7916 | |
| 7917 | if (targetInst !== null) { |
| 7918 | var nearestMounted = getNearestMountedFiber(targetInst); |
| 7919 | |
| 7920 | if (nearestMounted === null) { |
| 7921 | // This tree has been unmounted already. Dispatch without a target. |
| 7922 | targetInst = null; |
| 7923 | } else { |
| 7924 | var tag = nearestMounted.tag; |
| 7925 | |
| 7926 | if (tag === SuspenseComponent) { |
| 7927 | var instance = getSuspenseInstanceFromFiber(nearestMounted); |
| 7928 | |
| 7929 | if (instance !== null) { |
| 7930 | // Queue the event to be replayed later. Abort dispatching since we |
| 7931 | // don't want this event dispatched twice through the event system. |
| 7932 | // TODO: If this is the first discrete event in the queue. Schedule an increased |
| 7933 | // priority for this boundary. |
| 7934 | return instance; |
| 7935 | } // This shouldn't happen, something went wrong but to avoid blocking |
| 7936 | // the whole system, dispatch the event without a target. |
| 7937 | // TODO: Warn. |
| 7938 | |
| 7939 | |
| 7940 | targetInst = null; |
| 7941 | } else if (tag === HostRoot) { |
| 7942 | var root = nearestMounted.stateNode; |
| 7943 | |
| 7944 | if (root.hydrate) { |
| 7945 | // If this happens during a replay something went wrong and it might block |
| 7946 | // the whole system. |
| 7947 | return getContainerFromFiber(nearestMounted); |
| 7948 | } |
| 7949 | |
| 7950 | targetInst = null; |
| 7951 | } else if (nearestMounted !== targetInst) { |
| 7952 | // If we get an event (ex: img onload) before committing that |
| 7953 | // component's mount, ignore it for now (that is, treat it as if it was an |
| 7954 | // event on a non-React tree). We might also consider queueing events and |
| 7955 | // dispatching them after the mount. |
| 7956 | targetInst = null; |
| 7957 | } |
| 7958 | } |
| 7959 | } |
| 7960 | |
| 7961 | { |
| 7962 | dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst); |
| 7963 | } // We're not blocked on anything. |
| 7964 | |
| 7965 | |
| 7966 | return null; |
| 7967 | } |
| 7968 | |
| 7969 | // List derived from Gecko source code: |
no test coverage detected