(link: HTMLAnchorElement, modifiers: Modifiers)
| 90 | } |
| 91 | |
| 92 | export function shouldClientNavigate(link: HTMLAnchorElement, modifiers: Modifiers): boolean { |
| 93 | // Use getAttribute here instead of link.target. Firefox will default link.target to "_parent" when inside an iframe. |
| 94 | let target = link.getAttribute('target'); |
| 95 | return ( |
| 96 | (!target || target === '_self') && |
| 97 | link.origin === location.origin && |
| 98 | !link.hasAttribute('download') && |
| 99 | !modifiers.metaKey && // open in new tab (mac) |
| 100 | !modifiers.ctrlKey && // open in new tab (windows) |
| 101 | !modifiers.altKey && // download |
| 102 | !modifiers.shiftKey |
| 103 | ); |
| 104 | } |
| 105 | |
| 106 | export function openLink(target: HTMLAnchorElement, modifiers: Modifiers, setOpening = true): void { |
| 107 | let {metaKey, ctrlKey, altKey, shiftKey} = modifiers; |
no test coverage detected