Skip to content

Commit

Permalink
Use template literals instead of concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
rohit2sharma95 committed Mar 30, 2021
1 parent 8c3e6eb commit a3fcf49
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/src/modal.js
Expand Up @@ -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`
})
}

Expand Down
6 changes: 2 additions & 4 deletions js/src/util/index.js
Expand Up @@ -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
Expand Down Expand Up @@ -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}".`
)
}
})
Expand Down
2 changes: 1 addition & 1 deletion js/src/util/scrollbar.js
Expand Up @@ -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`
})
}

Expand Down

0 comments on commit a3fcf49

Please sign in to comment.