document.addEventListener('setup', function (e) { var themeSelector = e.detail.scope.querySelector('#theme-select'); themeSelector.addEventListener('change', function() { // get rid of old themes on body var options = Array.from(themeSelector.options) .forEach(function (option) { document.body.classList.remove(optionToTheme(option)); }); // add newly selected theme document.body.classList.add(optionToTheme(themeSelector.selectedOptions[0])); }); function optionToTheme(option) { return optionValue = 'theme--' + option.value; } });