(target: EventTarget | null, menuStack: readonly HTMLDivElement[])
| 84 | } |
| 85 | |
| 86 | function isNodeWithinMenuStack(target: EventTarget | null, menuStack: readonly HTMLDivElement[]) { |
| 87 | if (typeof Node !== "undefined" && target instanceof Node) { |
| 88 | return menuStack.some((menu) => menu.contains(target)); |
| 89 | } |
| 90 | if (!target || typeof target !== "object") { |
| 91 | return false; |
| 92 | } |
| 93 | |
| 94 | let current: unknown = target; |
| 95 | while (current && typeof current === "object") { |
| 96 | if (menuStack.includes(current as HTMLDivElement)) { |
| 97 | return true; |
| 98 | } |
| 99 | current = (current as { parent?: unknown }).parent; |
| 100 | } |
| 101 | return false; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Imperative DOM-based context menu for non-Electron environments. |
no outgoing calls
no test coverage detected