simulateBrowserEventDispatch.js — react Source File
Architecture documentation for simulateBrowserEventDispatch.js, a javascript file in the react codebase. 0 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 25f70bd8_f112_d04a_4a3f_6a33aba6b460["simulateBrowserEventDispatch.js"] 29c464eb_52d1_465c_432a_544e82213726["ReactInternalTestUtils.js"] 29c464eb_52d1_465c_432a_544e82213726 --> 25f70bd8_f112_d04a_4a3f_6a33aba6b460 style 25f70bd8_f112_d04a_4a3f_6a33aba6b460 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
const DOMException = require('domexception/webidl2js-wrapper');
const {nodeRoot} = require('jsdom/lib/jsdom/living/helpers/node');
const reportException = require('jsdom/lib/jsdom/living/helpers/runtime-script-errors');
const {
isNode,
isShadowRoot,
isSlotable,
getEventTargetParent,
isShadowInclusiveAncestor,
retarget,
} = require('jsdom/lib/jsdom/living/helpers/shadow-dom');
const {waitForMicrotasks} = require('./ReactInternalTestUtils');
const EVENT_PHASE = {
NONE: 0,
CAPTURING_PHASE: 1,
AT_TARGET: 2,
BUBBLING_PHASE: 3,
};
// Hack to get Symbol(wrapper) for target nodes.
let wrapperSymbol;
function wrapperForImpl(impl) {
if (impl == null) {
return null;
}
return impl[wrapperSymbol];
}
// This is a forked implementation of the jsdom dispatchEvent. The goal of
// this fork is to match the actual browser behavior of user events more closely.
// Real browser events yield to microtasks in-between event handlers, which is
// different from programmatically calling dispatchEvent (which does not yield).
// JSDOM correctly implements programmatic dispatchEvent, but sometimes we need
// to test the behavior of real user interactions, so we simulate it.
//
// It's async because we need to wait for microtasks between event handlers.
//
// Taken from:
// https://github.com/jsdom/jsdom/blob/2f8a7302a43fff92f244d5f3426367a8eb2b8896/lib/jsdom/living/events/EventTarget-impl.js#L88
async function simulateEventDispatch(eventImpl) {
if (eventImpl._dispatchFlag || !eventImpl._initializedFlag) {
throw DOMException.create(this._globalObject, [
'Tried to dispatch an uninitialized event',
'InvalidStateError',
]);
}
if (eventImpl.eventPhase !== EVENT_PHASE.NONE) {
throw DOMException.create(this._globalObject, [
'Tried to dispatch a dispatching event',
'InvalidStateError',
]);
}
eventImpl.isTrusted = false;
await _dispatch.call(this, eventImpl);
}
// ... (332 more lines)
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does simulateBrowserEventDispatch.js do?
simulateBrowserEventDispatch.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in simulateBrowserEventDispatch.js?
simulateBrowserEventDispatch.js defines 6 function(s): _dispatch, appendToEventPath, innerInvokeEventListeners, invokeEventListeners, simulateEventDispatch, wrapperForImpl.
What files import simulateBrowserEventDispatch.js?
simulateBrowserEventDispatch.js is imported by 1 file(s): ReactInternalTestUtils.js.
Where is simulateBrowserEventDispatch.js in the architecture?
simulateBrowserEventDispatch.js is located at packages/internal-test-utils/simulateBrowserEventDispatch.js (domain: BabelCompiler, subdomain: Entrypoint, directory: packages/internal-test-utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free