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

Function dispatchEvent

code/dependency-injection/public/app.js:6014–6038  ·  view source on GitHub ↗
(topLevelType, nativeEvent)

Source from the content-addressed store, hash-verified

6012}
6013
6014function dispatchEvent(topLevelType, nativeEvent) {
6015 if (!_enabled) {
6016 return;
6017 }
6018
6019 var nativeEventTarget = getEventTarget(nativeEvent);
6020 var targetInst = getClosestInstanceFromNode(nativeEventTarget);
6021 if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
6022 // If we get an event (ex: img onload) before committing that
6023 // component's mount, ignore it for now (that is, treat it as if it was an
6024 // event on a non-React tree). We might also consider queueing events and
6025 // dispatching them after the mount.
6026 targetInst = null;
6027 }
6028
6029 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
6030
6031 try {
6032 // Event queue being processed in the same cycle allows
6033 // `preventDefault`.
6034 batchedUpdates(handleTopLevel, bookKeeping);
6035 } finally {
6036 releaseTopLevelCallbackBookKeeping(bookKeeping);
6037 }
6038}
6039
6040var ReactDOMEventListener = Object.freeze({
6041 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