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