From 2d6732d5801fb19ad24f180f0adea7233b57f088 Mon Sep 17 00:00:00 2001 From: Albin Larsson Date: Fri, 15 Jun 2018 15:11:59 +0200 Subject: [PATCH] Replace switch in controls.createLabel with object literal --- src/js/controls.js | 31 ++++++++++--------------------- 1 file 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); + createLabel(type, attr = {}) { + // Skip i18n for abbreviations and brand names + const universals = { + pip: 'PIP', + airplay: 'AirPlay', + }; - switch (type) { - case 'pip': - text = 'PIP'; - break; - - case 'airplay': - text = 'AirPlay'; - break; - - default: - break; - } - - 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); },