MCPcopy
hub / github.com/codeaashu/claude-code / hitTest

Function hitTest

src/ink/hit-test.ts:18–41  ·  view source on GitHub ↗
(
  node: DOMElement,
  col: number,
  row: number,
)

Source from the content-addressed store, hash-verified

16 * via parentNode to find handlers.
17 */
18export function hitTest(
19 node: DOMElement,
20 col: number,
21 row: number,
22): DOMElement | null {
23 const rect = nodeCache.get(node)
24 if (!rect) return null
25 if (
26 col < rect.x ||
27 col >= rect.x + rect.width ||
28 row < rect.y ||
29 row >= rect.y + rect.height
30 ) {
31 return null
32 }
33 // Later siblings paint on top; reversed traversal returns topmost hit.
34 for (let i = node.childNodes.length - 1; i >= 0; i--) {
35 const child = node.childNodes[i]!
36 if (child.nodeName === '#text') continue
37 const hit = hitTest(child, col, row)
38 if (hit) return hit
39 }
40 return node
41}
42
43/**
44 * Hit-test the root at (col, row) and bubble a ClickEvent from the deepest

Callers 2

dispatchClickFunction · 0.85
dispatchHoverFunction · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected