From d80cb4766155a5392b112756af3a64ae11604a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 11 Jun 2022 23:44:14 +0200 Subject: Move clock component initialization to procedure. When the document was renederd as HTML the connectedCallback:s were ran before the document was there, meaning that the initial content of the tags were missing. This gives us controll over when its ran, and here also ensures that it's ran once the document is there. --- static/clock.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'static/clock.ts') diff --git a/static/clock.ts b/static/clock.ts index b0ddae00..fa975484 100644 --- a/static/clock.ts +++ b/static/clock.ts @@ -1,4 +1,7 @@ -export { SmallcalCellHighlight, Timebar } +export { + SmallcalCellHighlight, Timebar, + initialize_clock_components +} import { makeElement, date_to_percent } from './lib' @@ -104,7 +107,6 @@ class TodayButton extends ClockElement { (this.querySelector('a') as any).href = now.format("~Y-~m-~d.html") } } -customElements.define('today-button', TodayButton) class CurrentTime extends ClockElement { @@ -112,4 +114,8 @@ class CurrentTime extends ClockElement { this.textContent = now.format('~H:~M:~S') } } -customElements.define('current-time', CurrentTime) + +function initialize_clock_components() { + customElements.define('today-button', TodayButton) + customElements.define('current-time', CurrentTime) +} -- cgit v1.2.3