MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / dispatchEvent

Function dispatchEvent

code/styling/public/app.js:5921–5945  ·  view source on GitHub ↗
(topLevelType, nativeEvent)

Source from the content-addressed store, hash-verified

5919}
5920
5921function dispatchEvent(topLevelType, nativeEvent) {
5922 if (!_enabled) {
5923 return;
5924 }
5925
5926 var nativeEventTarget = getEventTarget(nativeEvent);
5927 var targetInst = getClosestInstanceFromNode(nativeEventTarget);
5928 if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
5929 // If we get an event (ex: img onload) before committing that
5930 // component's mount, ignore it for now (that is, treat it as if it was an
5931 // event on a non-React tree). We might also consider queueing events and
5932 // dispatching them after the mount.
5933 targetInst = null;
5934 }
5935
5936 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
5937
5938 try {
5939 // Event queue being processed in the same cycle allows
5940 // `preventDefault`.
5941 batchedUpdates(handleTopLevel, bookKeeping);
5942 } finally {
5943 releaseTopLevelCallbackBookKeeping(bookKeeping);
5944 }
5945}
5946
5947var ReactDOMEventListener = Object.freeze({
5948 get _enabled () { return _enabled; },

Callers

nothing calls this directly

Calls 6

getEventTargetFunction · 0.70
isFiberMountedFunction · 0.70
batchedUpdatesFunction · 0.70

Tested by

no test coverage detected