Home / Function/ accumulateSinglePhaseListeners() — react Function Reference

accumulateSinglePhaseListeners() — react Function Reference

Architecture documentation for the accumulateSinglePhaseListeners() function in DOMPluginEventSystem.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  ffe5dadd_1136_563b_f11c_19f1898c60be["accumulateSinglePhaseListeners()"]
  816b54e5_c63c_f8b2_68e8_0c637e281f03["DOMPluginEventSystem.js"]
  ffe5dadd_1136_563b_f11c_19f1898c60be -->|defined in| 816b54e5_c63c_f8b2_68e8_0c637e281f03
  4aec19a3_29c8_bb6a_c13b_8823cc60b026["extractEvents()"]
  4aec19a3_29c8_bb6a_c13b_8823cc60b026 -->|calls| ffe5dadd_1136_563b_f11c_19f1898c60be
  d0287fd0_244e_8562_5b35_de5bd863db97["extractEvents()"]
  d0287fd0_244e_8562_5b35_de5bd863db97 -->|calls| ffe5dadd_1136_563b_f11c_19f1898c60be
  f83d0a32_5c24_8096_449b_8e278ad03f9d["createDispatchListener()"]
  ffe5dadd_1136_563b_f11c_19f1898c60be -->|calls| f83d0a32_5c24_8096_449b_8e278ad03f9d
  dc523599_fdf9_701c_242d_51dc12a7153c["getListener()"]
  ffe5dadd_1136_563b_f11c_19f1898c60be -->|calls| dc523599_fdf9_701c_242d_51dc12a7153c
  style ffe5dadd_1136_563b_f11c_19f1898c60be fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom-bindings/src/events/DOMPluginEventSystem.js lines 712–824

export function accumulateSinglePhaseListeners(
  targetFiber: Fiber | null,
  reactName: string | null,
  nativeEventType: string,
  inCapturePhase: boolean,
  accumulateTargetOnly: boolean,
  nativeEvent: AnyNativeEvent,
): Array<DispatchListener> {
  const captureName = reactName !== null ? reactName + 'Capture' : null;
  const reactEventName = inCapturePhase ? captureName : reactName;
  let listeners: Array<DispatchListener> = [];

  let instance = targetFiber;
  let lastHostComponent = null;

  // Accumulate all instances and listeners via the target -> root path.
  while (instance !== null) {
    const {stateNode, tag} = instance;
    // Handle listeners that are on HostComponents (i.e. <div>)
    if (
      (tag === HostComponent ||
        tag === HostHoistable ||
        tag === HostSingleton) &&
      stateNode !== null
    ) {
      lastHostComponent = stateNode;

      // createEventHandle listeners
      if (enableCreateEventHandleAPI) {
        const eventHandlerListeners =
          getEventHandlerListeners(lastHostComponent);
        if (eventHandlerListeners !== null) {
          eventHandlerListeners.forEach(entry => {
            if (
              entry.type === nativeEventType &&
              entry.capture === inCapturePhase
            ) {
              listeners.push(
                createDispatchListener(
                  instance,
                  entry.callback,
                  (lastHostComponent: any),
                ),
              );
            }
          });
        }
      }

      // Standard React on* listeners, i.e. onClick or onClickCapture
      if (reactEventName !== null) {
        const listener = getListener(instance, reactEventName);
        if (listener != null) {
          listeners.push(
            createDispatchListener(instance, listener, lastHostComponent),
          );
        }
      }
    } else if (
      enableCreateEventHandleAPI &&
      enableScopeAPI &&
      tag === ScopeComponent &&
      lastHostComponent !== null &&
      stateNode !== null
    ) {
      // Scopes
      const reactScopeInstance = stateNode;
      const eventHandlerListeners =
        getEventHandlerListeners(reactScopeInstance);
      if (eventHandlerListeners !== null) {
        eventHandlerListeners.forEach(entry => {
          if (
            entry.type === nativeEventType &&
            entry.capture === inCapturePhase
          ) {
            listeners.push(
              createDispatchListener(
                instance,
                entry.callback,
                (lastHostComponent: any),
              ),

Domain

Subdomains

Frequently Asked Questions

What does accumulateSinglePhaseListeners() do?
accumulateSinglePhaseListeners() is a function in the react codebase, defined in packages/react-dom-bindings/src/events/DOMPluginEventSystem.js.
Where is accumulateSinglePhaseListeners() defined?
accumulateSinglePhaseListeners() is defined in packages/react-dom-bindings/src/events/DOMPluginEventSystem.js at line 712.
What does accumulateSinglePhaseListeners() call?
accumulateSinglePhaseListeners() calls 2 function(s): createDispatchListener, getListener.
What calls accumulateSinglePhaseListeners()?
accumulateSinglePhaseListeners() is called by 2 function(s): extractEvents, extractEvents.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free