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

Function handleTopLevel

code/one-direction-data-flow/public/app.js:5710–5735  ·  view source on GitHub ↗
(bookKeeping)

Source from the content-addressed store, hash-verified

5708}
5709
5710function handleTopLevel(bookKeeping) {
5711 var targetInst = bookKeeping.targetInst;
5712
5713 // Loop through the hierarchy, in case there's any nested components.
5714 // It's important that we build the array of ancestors before calling any
5715 // event handlers, because event handlers can modify the DOM, leading to
5716 // inconsistencies with ReactMount's node cache. See #1105.
5717 var ancestor = targetInst;
5718 do {
5719 if (!ancestor) {
5720 bookKeeping.ancestors.push(ancestor);
5721 break;
5722 }
5723 var root = findRootContainerNode(ancestor);
5724 if (!root) {
5725 break;
5726 }
5727 bookKeeping.ancestors.push(ancestor);
5728 ancestor = getClosestInstanceFromNode(root);
5729 } while (ancestor);
5730
5731 for (var i = 0; i < bookKeeping.ancestors.length; i++) {
5732 targetInst = bookKeeping.ancestors[i];
5733 runExtractedEventsInBatch(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
5734 }
5735}
5736
5737// TODO: can we stop exporting these?
5738var _enabled = true;

Callers

nothing calls this directly

Calls 4

findRootContainerNodeFunction · 0.70
getEventTargetFunction · 0.70

Tested by

no test coverage detected