()
| 110 | |
| 111 | timer: ReturnType<typeof setTimeout> = -1 as unknown as ReturnType<typeof setTimeout> |
| 112 | update() { |
| 113 | clearTimeout(this.timer) |
| 114 | if (!this.elements.size) return |
| 115 | |
| 116 | let nearestDistance = Infinity |
| 117 | this.updating = true |
| 118 | try { |
| 119 | for (const timeEl of this.elements) { |
| 120 | nearestDistance = Math.min(nearestDistance, getUnitFactor(timeEl)) |
| 121 | timeEl.update() |
| 122 | } |
| 123 | } finally { |
| 124 | this.updating = false |
| 125 | } |
| 126 | this.time = Math.min(60 * 60 * 1000, nearestDistance) |
| 127 | this.timer = setTimeout(() => this.update(), this.time) |
| 128 | this.time += Date.now() |
| 129 | } |
| 130 | })() |
| 131 | |
| 132 | export class RelativeTimeElement extends HTMLElement implements Intl.DateTimeFormatOptions { |
no test coverage detected