1
0
mirror of https://github.com/kognise/water.css.git synced 2025-08-08 14:16:58 +02:00

Fixed bug with switch button on first click

This commit is contained in:
Tyler Porter
2019-05-03 01:21:48 +00:00
parent 770040da41
commit c80427fd8d

View File

@@ -1,8 +1,4 @@
document.getElementById('switch').addEventListener('click', function() {
const stylesheet = document.getElementById('stylesheet')
if (stylesheet.getAttribute('href') === 'dist/dark.min.css') {
stylesheet.setAttribute('href', 'dist/light.min.css')
} else {
stylesheet.setAttribute('href', 'dist/dark.min.css')
}
})
const stylesheet = document.getElementById('stylesheet');
stylesheet.href = stylesheet.href.replace(/dark|light/, function(replaced) { return replaced === 'dark' ? 'light' : 'dark' });
});