Theme Controller Risks
"/home/yossef/notes/git/projects/maplibra/risks/Theme Controller Risks.md"
path: maplibra/risks/Theme Controller Risks.md
- **fileName**: Theme Controller Risks
- **Created on**: 2026-06-16 00:48:42
Theme Controller Risks
Migrated from: obs_vault
Parent: ../flows/Theme Change.md
This note covers the UI controller that applies theme changes through the map and the shell.
Main Source File
What It Does
- Watches the theme toggle button, storage events, and system color-scheme changes.
- Applies the chosen theme to the map, the layer manager, and the pathfinding controller.
Why It Matters
- This is the bridge between user intent and the actual visual theme state.
Risks
destroy()removes a handler reference that is not the same function object used duringaddEventListener, so teardown is likely incomplete.- The controller also adds anonymous storage and media-query listeners without a matching cleanup path.
toggleTheme()andapplyTheme()both call the persistence path, which can duplicatetheme-changedevents.- With
onThemeChangeprovided, controller propagation to layer manager and pathfinding controller is delegated outside the class.