From 87e3e0a04fe56de4159456f4a2952f7acb98f625 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 3 Jul 2026 09:40:48 +0000 Subject: [PATCH] fix: normalize the theme-toggle's persisted localStorage value An unexpected stored value (corrupted, or from a future version with different states) would be applied directly to data-theme, which the framework's selectors don't recognize, leaving the page in a mismatched state with a stale button label. Validate against the known states and fall back to 'auto' otherwise. Verified with Playwright: seeding localStorage with a garbage value before load now normalizes to auto (data-theme absent, label "Auto"), and the toggle still cycles correctly afterward. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_019y4H17xqMWoEgvxv3BRM98 --- copy-wip/github-pages-index.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/copy-wip/github-pages-index.html b/copy-wip/github-pages-index.html index 3f33a0a6..6a087c27 100644 --- a/copy-wip/github-pages-index.html +++ b/copy-wip/github-pages-index.html @@ -660,7 +660,10 @@

Developer

var btn = document.getElementById('theme-toggle'); var states = ['auto', 'dark', 'light']; var current = 'auto'; - try { current = localStorage.getItem('slashed-home-theme') || 'auto'; } catch (e) {} + try { + var stored = localStorage.getItem('slashed-home-theme'); + if (states.indexOf(stored) !== -1) current = stored; + } catch (e) {} function apply(state) { if (state === 'auto') document.documentElement.removeAttribute('data-theme'); else document.documentElement.setAttribute('data-theme', state);