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

Function traverseEnterLeave

code/new-context-api/public/app.js:1966–2004  ·  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

1964 * "entered" or "left" that element.
1965 */
1966function traverseEnterLeave(from, to, fn, argFrom, argTo) {
1967 var common = from && to ? getLowestCommonAncestor(from, to) : null;
1968 var pathFrom = [];
1969 while (true) {
1970 if (!from) {
1971 break;
1972 }
1973 if (from === common) {
1974 break;
1975 }
1976 var alternate = from.alternate;
1977 if (alternate !== null && alternate === common) {
1978 break;
1979 }
1980 pathFrom.push(from);
1981 from = getParent(from);
1982 }
1983 var pathTo = [];
1984 while (true) {
1985 if (!to) {
1986 break;
1987 }
1988 if (to === common) {
1989 break;
1990 }
1991 var _alternate = to.alternate;
1992 if (_alternate !== null && _alternate === common) {
1993 break;
1994 }
1995 pathTo.push(to);
1996 to = getParent(to);
1997 }
1998 for (var i = 0; i < pathFrom.length; i++) {
1999 fn(pathFrom[i], 'bubbled', argFrom);
2000 }
2001 for (var _i = pathTo.length; _i-- > 0;) {
2002 fn(pathTo[_i], 'captured', argTo);
2003 }
2004}
2005
2006/**
2007 * 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