-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Description
The generated ui-bundle/article.hbs template contains duplicated theme handling functions in two different script blocks, which increases maintenance overhead.
Current Behavior
The following functions appear twice in the generated template:
getStoredThemesetStoredThemegetPreferredThemesetTheme
First occurrence: In the <head> section (necessary to prevent FOUC - flash of unstyled content)
Second occurrence: In the body script for handling user interactions
Expected Behavior
The theme handling functions should be defined once and reused to avoid duplication.
Suggested Solution
Consider refactoring the template to expose these functions on a global object from the first script, which the second script can then consume. For example:
// In <head> script
window.themeUtils = {
getStoredTheme,
setStoredTheme,
getPreferredTheme,
setTheme
};
// In body script
const { getStoredTheme, setStoredTheme, getPreferredTheme, setTheme } = window.themeUtils;Impact
This duplication doesn't affect functionality but makes the template harder to maintain, as any changes to these functions need to be made in two places.
Found In
This issue was discovered during a code review by Gemini Code Assist on chibi-ui-2 PR #88.