1
0
mirror of https://github.com/kognise/water.css.git synced 2025-02-25 06:13:08 +01:00

Merge pull request #66 from pawptart/bugfix/switch-button

Fixed bug with switch button on first click
This commit is contained in:
kylejrp 2019-05-02 19:01:21 -07:00 committed by GitHub
commit 5733c6f96b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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' });
});