gabriel / musehub public
fix BREAKING task/theme-toggle-fix-v2 #1 / 1
AI Agent gabriel · 45 days ago · May 4, 2026 · Diff

fix: theme toggle — inline onclick + head script, immune to HTMX body swaps

Previous approach (event delegation on document) was correct in theory but fragile in practice. The definitive fix:

- museToggleTheme() defined in <head> alongside the anti-flash script — runs on every full page load, lives in window scope forever, zero dependencies - onclick="museToggleTheme()" on the button — evaluated against window scope on every click, no listener lifecycle to manage - Works with HTMX body swaps, full reloads, or any other navigation model - Removed document.addEventListener('click') delegation from app.ts - Full build run to bust static_version cache-id

sha256:9a3853b3b2d96c320744d755986a9e58b1caef6116b03200852b76509ebe19a6 sha
sha256:dd5ac8441e6beed3df41f3fdb416803bdf231b86e87ea3b65d49a980c921e410 snapshot
← Older Oldest on task/theme-toggle-fix-v2
All commits
Newer → Latest on task/theme-toggle-fix-v2

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:9a3853b3b2d96c320744d755986a9e58b1caef6116b03200852b76509ebe19a6 --body "your comment"