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

Function traverseEnterLeave

code/controlled-uncontrolled/public/app.js:1929–1967  ·  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

1927 * "entered" or "left" that element.
1928 */
1929function traverseEnterLeave(from, to, fn, argFrom, argTo) {
1930 var common = from && to ? getLowestCommonAncestor(from, to) : null;
1931 var pathFrom = [];
1932 while (true) {
1933 if (!from) {
1934 break;
1935 }
1936 if (from === common) {
1937 break;
1938 }
1939 var alternate = from.alternate;
1940 if (alternate !== null && alternate === common) {
1941 break;
1942 }
1943 pathFrom.push(from);
1944 from = getParent(from);
1945 }
1946 var pathTo = [];
1947 while (true) {
1948 if (!to) {
1949 break;
1950 }
1951 if (to === common) {
1952 break;
1953 }
1954 var _alternate = to.alternate;
1955 if (_alternate !== null && _alternate === common) {
1956 break;
1957 }
1958 pathTo.push(to);
1959 to = getParent(to);
1960 }
1961 for (var i = 0; i < pathFrom.length; i++) {
1962 fn(pathFrom[i], 'bubbled', argFrom);
1963 }
1964 for (var _i = pathTo.length; _i-- > 0;) {
1965 fn(pathTo[_i], 'captured', argTo);
1966 }
1967}
1968
1969/**
1970 * 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