diff --git a/changelog.md b/changelog.md index 2ad6e13..d81d13d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2026-03-03 - 8.4.1 - fix(statuspill) +wait for document.body before appending status pill when script loads before is parsed; defer via DOMContentLoaded or requestAnimationFrame + +- Guard against missing document.body to avoid errors when the script runs before the is parsed +- Retry showing on DOMContentLoaded if the document is still loading +- Fallback to requestAnimationFrame to schedule the show on the next frame if DOM is already parsed + ## 2026-02-24 - 8.4.0 - feat(utilityservers) add injectReload and noCache options and enable dev features by default diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 5fe3711..1d67c9e 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@api.global/typedserver', - version: '8.4.0', + version: '8.4.1', description: 'A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.' } diff --git a/ts_web_inject/typedserver_web.statuspill.ts b/ts_web_inject/typedserver_web.statuspill.ts index e7d9894..beab4c7 100644 --- a/ts_web_inject/typedserver_web.statuspill.ts +++ b/ts_web_inject/typedserver_web.statuspill.ts @@ -311,6 +311,15 @@ export class TypedserverStatusPill extends LitElement { */ public show(): void { if (!this.appended) { + if (!document.body) { + // Script loaded before was parsed (async module) — wait for DOM + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', () => this.show(), { once: true }); + } else { + requestAnimationFrame(() => this.show()); + } + return; + } document.body.appendChild(this); this.appended = true; }