dispatchEventForPluginEventSystem() — react Function Reference
Architecture documentation for the dispatchEventForPluginEventSystem() function in DOMPluginEventSystem.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 1be3a0b7_80ec_6d97_2d85_4a67f64ff80b["dispatchEventForPluginEventSystem()"] 816b54e5_c63c_f8b2_68e8_0c637e281f03["DOMPluginEventSystem.js"] 1be3a0b7_80ec_6d97_2d85_4a67f64ff80b -->|defined in| 816b54e5_c63c_f8b2_68e8_0c637e281f03 a88f3f22_dc1b_e053_dff6_69dfe164d116["dispatchEvent()"] a88f3f22_dc1b_e053_dff6_69dfe164d116 -->|calls| 1be3a0b7_80ec_6d97_2d85_4a67f64ff80b 9ea33c9d_8861_07e4_cd82_238384a96c0f["isReplayingEvent()"] 1be3a0b7_80ec_6d97_2d85_4a67f64ff80b -->|calls| 9ea33c9d_8861_07e4_cd82_238384a96c0f 59f88372_b7f2_6022_203c_89c9b50a4f4d["deferClickToDocumentForLegacyFBSupport()"] 1be3a0b7_80ec_6d97_2d85_4a67f64ff80b -->|calls| 59f88372_b7f2_6022_203c_89c9b50a4f4d 62765604_288e_f718_3f66_b0251d559664["isMatchingRootContainer()"] 1be3a0b7_80ec_6d97_2d85_4a67f64ff80b -->|calls| 62765604_288e_f718_3f66_b0251d559664 f9e9db51_d79e_2bec_6b9a_825840efe3e5["batchedUpdates()"] 1be3a0b7_80ec_6d97_2d85_4a67f64ff80b -->|calls| f9e9db51_d79e_2bec_6b9a_825840efe3e5 9a8085d6_7398_0661_fca1_1af88d83ebe8["dispatchEventsForPlugins()"] 1be3a0b7_80ec_6d97_2d85_4a67f64ff80b -->|calls| 9a8085d6_7398_0661_fca1_1af88d83ebe8 style 1be3a0b7_80ec_6d97_2d85_4a67f64ff80b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom-bindings/src/events/DOMPluginEventSystem.js lines 584–698
export function dispatchEventForPluginEventSystem(
domEventName: DOMEventName,
eventSystemFlags: EventSystemFlags,
nativeEvent: AnyNativeEvent,
targetInst: null | Fiber,
targetContainer: EventTarget,
): void {
let ancestorInst = targetInst;
if (
(eventSystemFlags & IS_EVENT_HANDLE_NON_MANAGED_NODE) === 0 &&
(eventSystemFlags & IS_NON_DELEGATED) === 0
) {
const targetContainerNode = ((targetContainer: any): Node);
// If we are using the legacy FB support flag, we
// defer the event to the null with a one
// time event listener so we can defer the event.
if (
enableLegacyFBSupport &&
// If our event flags match the required flags for entering
// FB legacy mode and we are processing the "click" event,
// then we can defer the event to the "document", to allow
// for legacy FB support, where the expected behavior was to
// match React < 16 behavior of delegated clicks to the doc.
domEventName === 'click' &&
(eventSystemFlags & SHOULD_NOT_DEFER_CLICK_FOR_FB_SUPPORT_MODE) === 0 &&
!isReplayingEvent(nativeEvent)
) {
deferClickToDocumentForLegacyFBSupport(domEventName, targetContainer);
return;
}
if (targetInst !== null) {
// The below logic attempts to work out if we need to change
// the target fiber to a different ancestor. We had similar logic
// in the legacy event system, except the big difference between
// systems is that the modern event system now has an event listener
// attached to each React Root and React Portal Root. Together,
// the DOM nodes representing these roots are the "rootContainer".
// To figure out which ancestor instance we should use, we traverse
// up the fiber tree from the target instance and attempt to find
// root boundaries that match that of our current "rootContainer".
// If we find that "rootContainer", we find the parent fiber
// sub-tree for that root and make that our ancestor instance.
let node: null | Fiber = targetInst;
mainLoop: while (true) {
if (node === null) {
return;
}
const nodeTag = node.tag;
if (nodeTag === HostRoot || nodeTag === HostPortal) {
let container = node.stateNode.containerInfo;
if (isMatchingRootContainer(container, targetContainerNode)) {
break;
}
if (nodeTag === HostPortal) {
// The target is a portal, but it's not the rootContainer we're looking for.
// Normally portals handle their own events all the way down to the root.
// So we should be able to stop now. However, we don't know if this portal
// was part of *our* root.
let grandNode = node.return;
while (grandNode !== null) {
const grandTag = grandNode.tag;
if (grandTag === HostRoot || grandTag === HostPortal) {
const grandContainer = grandNode.stateNode.containerInfo;
if (
isMatchingRootContainer(grandContainer, targetContainerNode)
) {
// This is the rootContainer we're looking for and we found it as
// a parent of the Portal. That means we can ignore it because the
// Portal will bubble through to us.
return;
}
}
grandNode = grandNode.return;
}
}
// Now we need to find it's corresponding host fiber in the other
// tree. To do this we can use getClosestInstanceFromNode, but we
// need to validate that the fiber is a host instance, otherwise
// we need to traverse up through the DOM till we find the correct
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does dispatchEventForPluginEventSystem() do?
dispatchEventForPluginEventSystem() is a function in the react codebase, defined in packages/react-dom-bindings/src/events/DOMPluginEventSystem.js.
Where is dispatchEventForPluginEventSystem() defined?
dispatchEventForPluginEventSystem() is defined in packages/react-dom-bindings/src/events/DOMPluginEventSystem.js at line 584.
What does dispatchEventForPluginEventSystem() call?
dispatchEventForPluginEventSystem() calls 5 function(s): batchedUpdates, deferClickToDocumentForLegacyFBSupport, dispatchEventsForPlugins, isMatchingRootContainer, isReplayingEvent.
What calls dispatchEventForPluginEventSystem()?
dispatchEventForPluginEventSystem() is called by 1 function(s): dispatchEvent.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free