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

Function traverseTwoPhase

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

* Simulates the traversal of a two-phase, capture/bubble event dispatch.

(inst, fn, arg)

Source from the content-addressed store, hash-verified

2454 * Simulates the traversal of a two-phase, capture/bubble event dispatch.
2455 */
2456function traverseTwoPhase(inst, fn, arg) {
2457 var path = [];
2458 while (inst) {
2459 path.push(inst);
2460 inst = getParent(inst);
2461 }
2462 var i = void 0;
2463 for (i = path.length; i-- > 0;) {
2464 fn(path[i], 'captured', arg);
2465 }
2466 for (i = 0; i < path.length; i++) {
2467 fn(path[i], 'bubbled', arg);
2468 }
2469}
2470
2471/**
2472 * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that

Calls 1

getParentFunction · 0.70

Tested by

no test coverage detected