MCPcopy Create free account
hub / github.com/reactjs/react-rails / handleTopLevel

Function handleTopLevel

lib/assets/react-source/development/react.js:7212–7255  ·  view source on GitHub ↗
(bookKeeping)

Source from the content-addressed store, hash-verified

7210 }
7211
7212 function handleTopLevel(bookKeeping) {
7213 var targetInst = bookKeeping.targetInst; // Loop through the hierarchy, in case there's any nested components.
7214 // It's important that we build the array of ancestors before calling any
7215 // event handlers, because event handlers can modify the DOM, leading to
7216 // inconsistencies with ReactMount's node cache. See #1105.
7217
7218 var ancestor = targetInst;
7219
7220 do {
7221 if (!ancestor) {
7222 var ancestors = bookKeeping.ancestors;
7223 ancestors.push(ancestor);
7224 break;
7225 }
7226
7227 var root = findRootContainerNode(ancestor);
7228
7229 if (!root) {
7230 break;
7231 }
7232
7233 var tag = ancestor.tag;
7234
7235 if (tag === HostComponent || tag === HostText) {
7236 bookKeeping.ancestors.push(ancestor);
7237 }
7238
7239 ancestor = getClosestInstanceFromNode(root);
7240 } while (ancestor);
7241
7242 for (var i = 0; i < bookKeeping.ancestors.length; i++) {
7243 targetInst = bookKeeping.ancestors[i];
7244 var eventTarget = getEventTarget(bookKeeping.nativeEvent);
7245 var topLevelType = bookKeeping.topLevelType;
7246 var nativeEvent = bookKeeping.nativeEvent;
7247 var eventSystemFlags = bookKeeping.eventSystemFlags; // If this is the first ancestor, we mark it on the system flags
7248
7249 if (i === 0) {
7250 eventSystemFlags |= IS_FIRST_ANCESTOR;
7251 }
7252
7253 runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, eventTarget, eventSystemFlags);
7254 }
7255 }
7256
7257 function dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst) {
7258 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags);

Callers

nothing calls this directly

Calls 4

findRootContainerNodeFunction · 0.85
getEventTargetFunction · 0.85

Tested by

no test coverage detected