The bug:
Occasionaly, the moon/sun svgs might not change when clicks happen like:
Why?:
The js uses the classes on svgs to determine what icon it is and swap it accordingly. Problem is, since the classes are on the svg icons and not the container that holds them (one with .dmb) class, the function does not swap icons when the click is registered on the container instead of svgs.
Solution:
Add a statement like
if(e.target.tagName == "SVG")
or something of the sort in .dmb's listener callback to prevent it from running if the click happens on the container instead of svg.
NOTE: an alternative solution might be to switch the classes on actual container. But it's more work so feel free to choose which one you wanna implement. Both would work fine.
The bug: Occasionaly, the moon/sun svgs might not change when clicks happen like:
Why?: The js uses the classes on svgs to determine what icon it is and swap it accordingly. Problem is, since the classes are on the svg icons and not the container that holds them (one with
.dmb
) class, the function does not swap icons when the click is registered on the container instead of svgs.Solution: Add a statement like
if(e.target.tagName == "SVG")
or something of the sort in.dmb
's listener callback to prevent it from running if the click happens on the container instead of svg.NOTE: an alternative solution might be to switch the classes on actual container. But it's more work so feel free to choose which one you wanna implement. Both would work fine.