aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlbin Larsson <mail@albinlarsson.com>2018-06-15 15:11:59 +0200
committerAlbin Larsson <mail@albinlarsson.com>2018-06-16 07:25:34 +0200
commit2d6732d5801fb19ad24f180f0adea7233b57f088 (patch)
tree9bbe19304bdd3d0ecc48df095f09290204b8d641 /src
parent88735e314646a2aaf0cf38935dcf11eff8290ebd (diff)
downloadplyr-2d6732d5801fb19ad24f180f0adea7233b57f088.tar.lz
plyr-2d6732d5801fb19ad24f180f0adea7233b57f088.tar.xz
plyr-2d6732d5801fb19ad24f180f0adea7233b57f088.zip
Replace switch in controls.createLabel with object literal
Diffstat (limited to 'src')
-rw-r--r--src/js/controls.js31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/js/controls.js b/src/js/controls.js
index efb718fe..1cbaa752 100644
--- a/src/js/controls.js
+++ b/src/js/controls.js
@@ -119,28 +119,17 @@ const controls = {
},
// Create hidden text label
- createLabel(type, attr) {
- let text = i18n.get(type, this.config);
- const attributes = Object.assign({}, attr);
-
- switch (type) {
- case 'pip':
- text = 'PIP';
- break;
-
- case 'airplay':
- text = 'AirPlay';
- break;
-
- default:
- break;
- }
+ createLabel(type, attr = {}) {
+ // Skip i18n for abbreviations and brand names
+ const universals = {
+ pip: 'PIP',
+ airplay: 'AirPlay',
+ };
- if ('class' in attributes) {
- attributes.class += ` ${this.config.classNames.hidden}`;
- } else {
- attributes.class = this.config.classNames.hidden;
- }
+ const text = universals[type] || i18n.get(type, this.config);
+ const attributes = Object.assign({}, attr, {
+ class: [attr.class, this.config.classNames.hidden].filter(Boolean).join(' '),
+ });
return createElement('span', attributes, text);
},