MCPcopy Index your code
hub / github.com/react/react / traverse

Function traverse

packages/react-dom/src/__tests__/ReactDOMSelection-test.internal.js:43–68  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

41 let length = 0;
42
43 function traverse(node) {
44 if (node.nodeType === Node.TEXT_NODE) {
45 if (node === anchorNode) {
46 start = length + anchorOffset;
47 }
48 if (node === focusNode) {
49 end = length + focusOffset;
50 }
51 length += node.nodeValue.length;
52 return;
53 }
54
55 for (let i = 0; true; i++) {
56 if (node === anchorNode && i === anchorOffset) {
57 start = length;
58 }
59 if (node === focusNode && i === focusOffset) {
60 end = length;
61 }
62 if (i === node.childNodes.length) {
63 break;
64 }
65 const n = node.childNodes[i];
66 traverse(n);
67 }
68 }
69 traverse(outerNode);
70
71 if (start === null || end === null) {

Callers 6

runReactCompilerImplFunction · 0.85
runReactCompilerImplFunction · 0.85
transformFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected