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

Function traverseEnterLeave

code/one-direction-data-flow/public/app.js:2478–2516  ·  view source on GitHub ↗

* Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that * should would receive a `mouseEnter` or `mouseLeave` event. * * Does not invoke the callback on the nearest common ancestor because nothing * "entered" or "left" that element.

(from, to, fn, argFrom, argTo)

Source from the content-addressed store, hash-verified

2476 * "entered" or "left" that element.
2477 */
2478function traverseEnterLeave(from, to, fn, argFrom, argTo) {
2479 var common = from && to ? getLowestCommonAncestor(from, to) : null;
2480 var pathFrom = [];
2481 while (true) {
2482 if (!from) {
2483 break;
2484 }
2485 if (from === common) {
2486 break;
2487 }
2488 var alternate = from.alternate;
2489 if (alternate !== null && alternate === common) {
2490 break;
2491 }
2492 pathFrom.push(from);
2493 from = getParent(from);
2494 }
2495 var pathTo = [];
2496 while (true) {
2497 if (!to) {
2498 break;
2499 }
2500 if (to === common) {
2501 break;
2502 }
2503 var _alternate = to.alternate;
2504 if (_alternate !== null && _alternate === common) {
2505 break;
2506 }
2507 pathTo.push(to);
2508 to = getParent(to);
2509 }
2510 for (var i = 0; i < pathFrom.length; i++) {
2511 fn(pathFrom[i], 'bubbled', argFrom);
2512 }
2513 for (var _i = pathTo.length; _i-- > 0;) {
2514 fn(pathTo[_i], 'captured', argTo);
2515 }
2516}
2517
2518/**
2519 * Some event types have a notion of different registration names for different

Callers 1

Calls 2

getLowestCommonAncestorFunction · 0.70
getParentFunction · 0.70

Tested by

no test coverage detected