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

Function traverseEnterLeave

code/communication/public/app.js:2640–2678  ·  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

2638 * "entered" or "left" that element.
2639 */
2640function traverseEnterLeave(from, to, fn, argFrom, argTo) {
2641 var common = from && to ? getLowestCommonAncestor(from, to) : null;
2642 var pathFrom = [];
2643 while (true) {
2644 if (!from) {
2645 break;
2646 }
2647 if (from === common) {
2648 break;
2649 }
2650 var alternate = from.alternate;
2651 if (alternate !== null && alternate === common) {
2652 break;
2653 }
2654 pathFrom.push(from);
2655 from = getParent(from);
2656 }
2657 var pathTo = [];
2658 while (true) {
2659 if (!to) {
2660 break;
2661 }
2662 if (to === common) {
2663 break;
2664 }
2665 var _alternate = to.alternate;
2666 if (_alternate !== null && _alternate === common) {
2667 break;
2668 }
2669 pathTo.push(to);
2670 to = getParent(to);
2671 }
2672 for (var i = 0; i < pathFrom.length; i++) {
2673 fn(pathFrom[i], 'bubbled', argFrom);
2674 }
2675 for (var _i = pathTo.length; _i-- > 0;) {
2676 fn(pathTo[_i], 'captured', argTo);
2677 }
2678}
2679
2680/**
2681 * 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