(topLevelType, eventSystemFlags, container, nativeEvent)
| 4338 | } // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked. |
| 4339 | |
| 4340 | function attemptToDispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent) { |
| 4341 | // TODO: Warn if _enabled is false. |
| 4342 | var nativeEventTarget = getEventTarget(nativeEvent); |
| 4343 | var targetInst = getClosestInstanceFromNode(nativeEventTarget); |
| 4344 | |
| 4345 | if (targetInst !== null) { |
| 4346 | var nearestMounted = getNearestMountedFiber(targetInst); |
| 4347 | |
| 4348 | if (nearestMounted === null) { |
| 4349 | // This tree has been unmounted already. Dispatch without a target. |
| 4350 | targetInst = null; |
| 4351 | } else { |
| 4352 | var tag = nearestMounted.tag; |
| 4353 | |
| 4354 | if (tag === SuspenseComponent) { |
| 4355 | var instance = getSuspenseInstanceFromFiber(nearestMounted); |
| 4356 | |
| 4357 | if (instance !== null) { |
| 4358 | // Queue the event to be replayed later. Abort dispatching since we |
| 4359 | // don't want this event dispatched twice through the event system. |
| 4360 | // TODO: If this is the first discrete event in the queue. Schedule an increased |
| 4361 | // priority for this boundary. |
| 4362 | return instance; |
| 4363 | } // This shouldn't happen, something went wrong but to avoid blocking |
| 4364 | // the whole system, dispatch the event without a target. |
| 4365 | // TODO: Warn. |
| 4366 | |
| 4367 | |
| 4368 | targetInst = null; |
| 4369 | } else if (tag === HostRoot) { |
| 4370 | var root = nearestMounted.stateNode; |
| 4371 | |
| 4372 | if (root.hydrate) { |
| 4373 | // If this happens during a replay something went wrong and it might block |
| 4374 | // the whole system. |
| 4375 | return getContainerFromFiber(nearestMounted); |
| 4376 | } |
| 4377 | |
| 4378 | targetInst = null; |
| 4379 | } else if (nearestMounted !== targetInst) { |
| 4380 | // If we get an event (ex: img onload) before committing that |
| 4381 | // component's mount, ignore it for now (that is, treat it as if it was an |
| 4382 | // event on a non-React tree). We might also consider queueing events and |
| 4383 | // dispatching them after the mount. |
| 4384 | targetInst = null; |
| 4385 | } |
| 4386 | } |
| 4387 | } |
| 4388 | |
| 4389 | { |
| 4390 | dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst); |
| 4391 | } // We're not blocked on anything. |
| 4392 | |
| 4393 | |
| 4394 | return null; |
| 4395 | } |
| 4396 | |
| 4397 | // List derived from Gecko source code: |
no test coverage detected