(el: HTMLElement | null)
| 71 | } |
| 72 | |
| 73 | function getEffectiveBackground(el: HTMLElement | null): string { |
| 74 | const fallbackBackground: RgbaColor = { r: 17, g: 17, b: 17, a: 1 } |
| 75 | |
| 76 | let node: HTMLElement | null = el |
| 77 | let blended: RgbaColor | null = null |
| 78 | |
| 79 | while (node) { |
| 80 | const bg = window.getComputedStyle(node).backgroundColor |
| 81 | const parsed = parseCssColorToRgba(bg) |
| 82 | if (parsed && parsed.a > 0) { |
| 83 | blended = blended ? compositeOver(blended, parsed) : parsed |
| 84 | if (blended.a >= 0.999) { |
| 85 | return toOpaqueRgbString(blended) |
| 86 | } |
| 87 | } |
| 88 | node = node.parentElement |
| 89 | } |
| 90 | |
| 91 | if (!blended) { |
| 92 | return toOpaqueRgbString(fallbackBackground) |
| 93 | } |
| 94 | |
| 95 | return toOpaqueRgbString(compositeOver(blended, fallbackBackground)) |
| 96 | } |
| 97 | |
| 98 | function triggerDownload(href: string, filename: string) { |
| 99 | const a = document.createElement('a') |
no test coverage detected