From a3fcf495af9e1a88d444b0f23685cc2cc054ee5a Mon Sep 17 00:00:00 2001 From: Rohit Sharma Date: Tue, 30 Mar 2021 11:10:32 +0530 Subject: [PATCH] Use template literals instead of concatenation --- js/src/modal.js | 2 +- js/src/util/index.js | 6 ++---- js/src/util/scrollbar.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/js/src/modal.js b/js/src/modal.js index 2966f03fb5d1..4ce910dc6a5b 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -474,7 +474,7 @@ class Modal extends BaseComponent { const actualValue = element.style[styleProp] const calculatedValue = window.getComputedStyle(element)[styleProp] Manipulator.setDataAttribute(element, styleProp, actualValue) - element.style[styleProp] = callback(Number.parseFloat(calculatedValue)) + 'px' + element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px` }) } diff --git a/js/src/util/index.js b/js/src/util/index.js index a7578b18004a..cc35d8a37c4c 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -48,7 +48,7 @@ const getSelector = element => { // Just in case some CMS puts out a full URL with the anchor appended if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { - hrefAttr = '#' + hrefAttr.split('#')[1] + hrefAttr = `#${hrefAttr.split('#')[1]}` } selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null @@ -128,9 +128,7 @@ const typeCheckConfig = (componentName, config, configTypes) => { if (!new RegExp(expectedTypes).test(valueType)) { throw new TypeError( - `${componentName.toUpperCase()}: ` + - `Option "${property}" provided type "${valueType}" ` + - `but expected type "${expectedTypes}".` + `${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".` ) } }) diff --git a/js/src/util/scrollbar.js b/js/src/util/scrollbar.js index 3e619ef51e43..e63a66bf218b 100644 --- a/js/src/util/scrollbar.js +++ b/js/src/util/scrollbar.js @@ -35,7 +35,7 @@ const _setElementAttributes = (selector, styleProp, callback) => { const actualValue = element.style[styleProp] const calculatedValue = window.getComputedStyle(element)[styleProp] Manipulator.setDataAttribute(element, styleProp, actualValue) - element.style[styleProp] = callback(Number.parseFloat(calculatedValue)) + 'px' + element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px` }) }