({
href = '',
download = '',
click = () => undefined,
}: AnchorElementBuilderOptions = {})
| 427 | } |
| 428 | |
| 429 | export function buildAnchorElement({ |
| 430 | href = '', |
| 431 | download = '', |
| 432 | click = () => undefined, |
| 433 | }: AnchorElementBuilderOptions = {}): HTMLAnchorElement { |
| 434 | const anchor = document.createElement('a'); |
| 435 | let currentHref = href; |
| 436 | let currentDownload = download; |
| 437 | |
| 438 | Object.defineProperties(anchor, { |
| 439 | click: { |
| 440 | configurable: true, |
| 441 | value: click, |
| 442 | }, |
| 443 | download: { |
| 444 | configurable: true, |
| 445 | get: () => currentDownload, |
| 446 | set: (value: string) => { |
| 447 | currentDownload = value; |
| 448 | }, |
| 449 | }, |
| 450 | href: { |
| 451 | configurable: true, |
| 452 | get: () => currentHref, |
| 453 | set: (value: string) => { |
| 454 | currentHref = value; |
| 455 | }, |
| 456 | }, |
| 457 | }); |
| 458 | |
| 459 | return anchor; |
| 460 | } |
| 461 | |
| 462 | export function buildTimeoutHandle(): ReturnType<typeof setTimeout> { |
| 463 | const handle = setTimeout(() => undefined, 0); |
no outgoing calls
no test coverage detected