( node: DOMElement, col: number, row: number, )
| 16 | * via parentNode to find handlers. |
| 17 | */ |
| 18 | export 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 |
no test coverage detected