Replace switch in controls.updateSetting with condition

This commit is contained in:
Albin Larsson 2018-06-15 12:48:37 +02:00
parent c373ed72d7
commit 88735e3146

41
src/js/controls.js vendored
View File

@ -724,32 +724,27 @@ const controls = {
let value = null; let value = null;
let list = container; let list = container;
switch (setting) { if (setting === 'captions') {
case 'captions': value = this.currentTrack;
value = this.currentTrack; } else {
break; value = !is.empty(input) ? input : this[setting];
default: // Get default
value = !is.empty(input) ? input : this[setting]; if (is.empty(value)) {
value = this.config[setting].default;
}
// Get default // Unsupported value
if (is.empty(value)) { if (!is.empty(this.options[setting]) && !this.options[setting].includes(value)) {
value = this.config[setting].default; this.debug.warn(`Unsupported value of '${value}' for ${setting}`);
} return;
}
// Unsupported value // Disabled value
if (!is.empty(this.options[setting]) && !this.options[setting].includes(value)) { if (!this.config[setting].options.includes(value)) {
this.debug.warn(`Unsupported value of '${value}' for ${setting}`); this.debug.warn(`Disabled value of '${value}' for ${setting}`);
return; return;
} }
// Disabled value
if (!this.config[setting].options.includes(value)) {
this.debug.warn(`Disabled value of '${value}' for ${setting}`);
return;
}
break;
} }
// Get the list if we need to // Get the list if we need to