Skip to content

Commit

Permalink
fix(color-utils): refactored **intToHex** function
Browse files Browse the repository at this point in the history
.padStart, while covered under babel-polyfill, is still not fully supported on very recent browser
versions

fixes #3042
  • Loading branch information
johnleider committed Jan 19, 2018
1 parent 1e1d364 commit 7b7cb19
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/util/colorUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@ export function colorToInt (color) {
* @returns {string}
*/
export function intToHex (color) {
return '#' + color.toString(16).padStart(6, '0')
color = color.toString(16)

while (color.length < 6) color = `0${color}`

return `#${color}`
}

0 comments on commit 7b7cb19

Please sign in to comment.