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

Function traverseEnterLeave

code/higher-order-components/public/app.js:2599–2637  ·  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

2597 * "entered" or "left" that element.
2598 */
2599function traverseEnterLeave(from, to, fn, argFrom, argTo) {
2600 var common = from && to ? getLowestCommonAncestor(from, to) : null;
2601 var pathFrom = [];
2602 while (true) {
2603 if (!from) {
2604 break;
2605 }
2606 if (from === common) {
2607 break;
2608 }
2609 var alternate = from.alternate;
2610 if (alternate !== null && alternate === common) {
2611 break;
2612 }
2613 pathFrom.push(from);
2614 from = getParent(from);
2615 }
2616 var pathTo = [];
2617 while (true) {
2618 if (!to) {
2619 break;
2620 }
2621 if (to === common) {
2622 break;
2623 }
2624 var _alternate = to.alternate;
2625 if (_alternate !== null && _alternate === common) {
2626 break;
2627 }
2628 pathTo.push(to);
2629 to = getParent(to);
2630 }
2631 for (var i = 0; i < pathFrom.length; i++) {
2632 fn(pathFrom[i], 'bubbled', argFrom);
2633 }
2634 for (var _i = pathTo.length; _i-- > 0;) {
2635 fn(pathTo[_i], 'captured', argTo);
2636 }
2637}
2638
2639/**
2640 * 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