Fix theme toggle conflicts from duplicate script inclusion and overlapping listeners#76
Open
linseyqiu-hub wants to merge 1 commit into
Open
Fix theme toggle conflicts from duplicate script inclusion and overlapping listeners#76linseyqiu-hub wants to merge 1 commit into
linseyqiu-hub wants to merge 1 commit into
Conversation
Fix theme toggle conflicts from duplicate script inclusion and overlapping listeners Body The theme toggle button malfunction was caused by duplicate script loading and competing event listeners. Issues identified: theme-toggle.js was included twice in index.html (line 132 and line 245), resulting in duplicate DOMContentLoaded handlers and click listeners being registered Both script.js and theme-toggle.js attached click listeners to the theme toggle button, creating overlapping behavior and inconsistent state changes The duplicated listeners obscured the root cause and made debugging confusing Changes made: Commented out the duplicate <script src="js/theme-toggle.js"></script> at index.html:132, keeping the intended include at line 245 Removed the redundant theme toggle click listener from script.js Refactored theme-toggle.js so theme toggling is handled exclusively by a single, centralized event listener This eliminates duplicate execution, clarifies ownership of theme logic, and restores predictable toggle behavior.
Owner
|
Resolve Conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The theme toggle button malfunction was caused by duplicate script loading and competing event listeners.
Issues identified:
theme-toggle.js was included twice in index.html (line 132 and line 245), resulting in duplicate DOMContentLoaded handlers and click listeners being registered
Both script.js and theme-toggle.js attached click listeners to the theme toggle button, creating overlapping behavior and inconsistent state changes
The duplicated listeners obscured the root cause and made debugging confusing
Changes made:
Commented out the duplicate <script src="js/theme-toggle.js"></script> at index.html:132, keeping the intended include at line 245
Removed the redundant theme toggle click listener from script.js
Refactored theme-toggle.js so theme toggling is handled exclusively by a single, centralized event listener
This eliminates duplicate execution, clarifies ownership of theme logic, and restores predictable toggle behavior.