(target: Element, open: (link: HTMLAnchorElement) => void)
| 142 | (openLink as any).isOpening = false; |
| 143 | |
| 144 | function getSyntheticLink(target: Element, open: (link: HTMLAnchorElement) => void) { |
| 145 | if (target instanceof HTMLAnchorElement) { |
| 146 | open(target); |
| 147 | } else if (target.hasAttribute('data-href')) { |
| 148 | let link = document.createElement('a'); |
| 149 | link.href = target.getAttribute('data-href')!; |
| 150 | if (target.hasAttribute('data-target')) { |
| 151 | link.target = target.getAttribute('data-target')!; |
| 152 | } |
| 153 | if (target.hasAttribute('data-rel')) { |
| 154 | link.rel = target.getAttribute('data-rel')!; |
| 155 | } |
| 156 | if (target.hasAttribute('data-download')) { |
| 157 | link.download = target.getAttribute('data-download')!; |
| 158 | } |
| 159 | if (target.hasAttribute('data-ping')) { |
| 160 | link.ping = target.getAttribute('data-ping')!; |
| 161 | } |
| 162 | if (target.hasAttribute('data-referrer-policy')) { |
| 163 | link.referrerPolicy = target.getAttribute('data-referrer-policy')!; |
| 164 | } |
| 165 | target.appendChild(link); |
| 166 | open(link); |
| 167 | target.removeChild(link); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | function openSyntheticLink(target: Element, modifiers: Modifiers) { |
| 172 | getSyntheticLink(target, link => openLink(link, modifiers)); |
no test coverage detected