Home / Function/ innerInvokeEventListeners() — react Function Reference

innerInvokeEventListeners() — react Function Reference

Architecture documentation for the innerInvokeEventListeners() function in simulateBrowserEventDispatch.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  305baca9_94d3_b953_575b_ea866ba7cb40["innerInvokeEventListeners()"]
  25f70bd8_f112_d04a_4a3f_6a33aba6b460["simulateBrowserEventDispatch.js"]
  305baca9_94d3_b953_575b_ea866ba7cb40 -->|defined in| 25f70bd8_f112_d04a_4a3f_6a33aba6b460
  be0b20e5_61c4_ad85_29c7_9975c5ab309c["invokeEventListeners()"]
  be0b20e5_61c4_ad85_29c7_9975c5ab309c -->|calls| 305baca9_94d3_b953_575b_ea866ba7cb40
  5f9bdee1_5ef6_6ad1_84f6_866ec451180c["wrapperForImpl()"]
  305baca9_94d3_b953_575b_ea866ba7cb40 -->|calls| 5f9bdee1_5ef6_6ad1_84f6_866ec451180c
  style 305baca9_94d3_b953_575b_ea866ba7cb40 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/internal-test-utils/simulateBrowserEventDispatch.js lines 279–367

async function innerInvokeEventListeners(
  eventImpl,
  listeners,
  phase,
  itemInShadowTree,
) {
  let found = false;

  const {type, target} = eventImpl;
  const wrapper = wrapperForImpl(target);

  if (!listeners || !listeners[type]) {
    return found;
  }

  // Copy event listeners before iterating since the list can be modified during the iteration.
  const handlers = listeners[type].slice();

  for (let i = 0; i < handlers.length; i++) {
    const listener = handlers[i];
    const {capture, once, passive} = listener.options;

    // Check if the event listener has been removed since the listeners has been cloned.
    if (!listeners[type].includes(listener)) {
      continue;
    }

    found = true;

    if (
      (phase === 'capturing' && !capture) ||
      (phase === 'bubbling' && capture)
    ) {
      continue;
    }

    if (once) {
      listeners[type].splice(listeners[type].indexOf(listener), 1);
    }

    let window = null;
    if (wrapper && wrapper._document) {
      // Triggered by Window
      window = wrapper;
    } else if (target._ownerDocument) {
      // Triggered by most webidl2js'ed instances
      window = target._ownerDocument._defaultView;
    } else if (wrapper._ownerDocument) {
      // Currently triggered by some non-webidl2js things
      window = wrapper._ownerDocument._defaultView;
    }

    let currentEvent;
    if (window) {
      currentEvent = window._currentEvent;
      if (!itemInShadowTree) {
        window._currentEvent = eventImpl;
      }
    }

    if (passive) {
      eventImpl._inPassiveListenerFlag = true;
    }

    try {
      listener.callback.call(eventImpl.currentTarget, eventImpl);
    } catch (e) {
      if (window) {
        reportException(window, e);
      }
      // Errors in window-less documents just get swallowed... can you think of anything better?
    }

    eventImpl._inPassiveListenerFlag = false;

    if (window) {
      window._currentEvent = currentEvent;
    }

    if (eventImpl._stopImmediatePropagationFlag) {
      return found;

Domain

Subdomains

Frequently Asked Questions

What does innerInvokeEventListeners() do?
innerInvokeEventListeners() is a function in the react codebase, defined in packages/internal-test-utils/simulateBrowserEventDispatch.js.
Where is innerInvokeEventListeners() defined?
innerInvokeEventListeners() is defined in packages/internal-test-utils/simulateBrowserEventDispatch.js at line 279.
What does innerInvokeEventListeners() call?
innerInvokeEventListeners() calls 1 function(s): wrapperForImpl.
What calls innerInvokeEventListeners()?
innerInvokeEventListeners() is called by 1 function(s): invokeEventListeners.

Analyze Your Own Codebase

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

Try Supermodel Free