(target: EventTarget | null)
| 6 | // A link to a page of its own on this origin (not a root, not the page on |
| 7 | // screen), opened in this tab. |
| 8 | const pageLink = (target: EventTarget | null): HTMLAnchorElement | null => { |
| 9 | const anchor = (target as Element | null)?.closest?.('a[href]'); |
| 10 | if ( |
| 11 | !(anchor instanceof HTMLAnchorElement) || |
| 12 | anchor.origin !== window.location.origin || |
| 13 | anchor.target || |
| 14 | anchor.hasAttribute('download') || |
| 15 | anchor.closest('[data-shell-row]') || |
| 16 | anchor.pathname === window.location.pathname || |
| 17 | isRootView(owningRoot(anchor.pathname), anchor.pathname) |
| 18 | ) { |
| 19 | return null; |
| 20 | } |
| 21 | return anchor; |
| 22 | }; |
| 23 | |
| 24 | const pathOf = (anchor: HTMLAnchorElement): string => |
| 25 | `${anchor.pathname}${anchor.search}${anchor.hash}`; |
no test coverage detected