MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / buildAnchorElement

Function buildAnchorElement

src/test/builders/browserFakes.ts:429–460  ·  view source on GitHub ↗
({
  href = '',
  download = '',
  click = () => undefined,
}: AnchorElementBuilderOptions = {})

Source from the content-addressed store, hash-verified

427}
428
429export 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
462export function buildTimeoutHandle(): ReturnType<typeof setTimeout> {
463 const handle = setTimeout(() => undefined, 0);

Callers 5

download.test.tsFile · 0.90
writers.test.tsFile · 0.90
builders.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected