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

Function handleTopLevel

code/controlled-uncontrolled/public/app.js:5161–5186  ·  view source on GitHub ↗
(bookKeeping)

Source from the content-addressed store, hash-verified

5159}
5160
5161function handleTopLevel(bookKeeping) {
5162 var targetInst = bookKeeping.targetInst;
5163
5164 // Loop through the hierarchy, in case there's any nested components.
5165 // It's important that we build the array of ancestors before calling any
5166 // event handlers, because event handlers can modify the DOM, leading to
5167 // inconsistencies with ReactMount's node cache. See #1105.
5168 var ancestor = targetInst;
5169 do {
5170 if (!ancestor) {
5171 bookKeeping.ancestors.push(ancestor);
5172 break;
5173 }
5174 var root = findRootContainerNode(ancestor);
5175 if (!root) {
5176 break;
5177 }
5178 bookKeeping.ancestors.push(ancestor);
5179 ancestor = getClosestInstanceFromNode(root);
5180 } while (ancestor);
5181
5182 for (var i = 0; i < bookKeeping.ancestors.length; i++) {
5183 targetInst = bookKeeping.ancestors[i];
5184 runExtractedEventsInBatch(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
5185 }
5186}
5187
5188// TODO: can we stop exporting these?
5189var _enabled = true;

Callers

nothing calls this directly

Calls 4

findRootContainerNodeFunction · 0.70
getEventTargetFunction · 0.70

Tested by

no test coverage detected