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

Function dispatchEvent

code/communication/public/app.js:5956–5980  ·  view source on GitHub ↗
(topLevelType, nativeEvent)

Source from the content-addressed store, hash-verified

5954}
5955
5956function dispatchEvent(topLevelType, nativeEvent) {
5957 if (!_enabled) {
5958 return;
5959 }
5960
5961 var nativeEventTarget = getEventTarget(nativeEvent);
5962 var targetInst = getClosestInstanceFromNode(nativeEventTarget);
5963 if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
5964 // If we get an event (ex: img onload) before committing that
5965 // component's mount, ignore it for now (that is, treat it as if it was an
5966 // event on a non-React tree). We might also consider queueing events and
5967 // dispatching them after the mount.
5968 targetInst = null;
5969 }
5970
5971 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
5972
5973 try {
5974 // Event queue being processed in the same cycle allows
5975 // `preventDefault`.
5976 batchedUpdates(handleTopLevel, bookKeeping);
5977 } finally {
5978 releaseTopLevelCallbackBookKeeping(bookKeeping);
5979 }
5980}
5981
5982var ReactDOMEventListener = Object.freeze({
5983 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