diff options
author | Albin Larsson <mail@albinlarsson.com> | 2018-06-15 12:48:37 +0200 |
---|---|---|
committer | Albin Larsson <mail@albinlarsson.com> | 2018-06-15 15:57:10 +0200 |
commit | 88735e314646a2aaf0cf38935dcf11eff8290ebd (patch) | |
tree | cbd4af8a5daf15e9cdb5a00480c599da14faa195 /src/js/controls.js | |
parent | c373ed72d78a221c03190e93f1e49d78c1e2b93f (diff) | |
download | plyr-88735e314646a2aaf0cf38935dcf11eff8290ebd.tar.lz plyr-88735e314646a2aaf0cf38935dcf11eff8290ebd.tar.xz plyr-88735e314646a2aaf0cf38935dcf11eff8290ebd.zip |
Replace switch in controls.updateSetting with condition
Diffstat (limited to 'src/js/controls.js')
-rw-r--r-- | src/js/controls.js | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/js/controls.js b/src/js/controls.js index f091555f..efb718fe 100644 --- a/src/js/controls.js +++ b/src/js/controls.js @@ -724,32 +724,27 @@ const controls = { let value = null; let list = container; - switch (setting) { - case 'captions': - value = this.currentTrack; - break; - - default: - value = !is.empty(input) ? input : this[setting]; - - // Get default - if (is.empty(value)) { - value = this.config[setting].default; - } + if (setting === 'captions') { + value = this.currentTrack; + } else { + value = !is.empty(input) ? input : this[setting]; - // Unsupported value - if (!is.empty(this.options[setting]) && !this.options[setting].includes(value)) { - this.debug.warn(`Unsupported value of '${value}' for ${setting}`); - return; - } + // Get default + if (is.empty(value)) { + value = this.config[setting].default; + } - // Disabled value - if (!this.config[setting].options.includes(value)) { - this.debug.warn(`Disabled value of '${value}' for ${setting}`); - return; - } + // Unsupported value + if (!is.empty(this.options[setting]) && !this.options[setting].includes(value)) { + this.debug.warn(`Unsupported value of '${value}' for ${setting}`); + return; + } - break; + // Disabled value + if (!this.config[setting].options.includes(value)) { + this.debug.warn(`Disabled value of '${value}' for ${setting}`); + return; + } } // Get the list if we need to |