dark-mode-example
dark-mode-example copied to clipboard
Deprecated code.
// Listen for changes in the OS settings useDark.addListener(function(evt) { toggleDarkMode(evt.matches); });
Should use addEventListener to future proof the code.
@23Chromosomes Thanks for the suggestion. The reason we used the deprecated version is because older versions of Safari (both on iOS and macOS) don't support addEventListener. Newer versions do though, but to be properly backwards-compatible the best approach would be to check if addEventListener exists on MediaQueryList and use the one that exists.