This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
pxToRem() doesn't support negative values #394
Labels
🧰 bug
Something isn't working
good first issue
Good for newcomers
help wanted
Extra attention is needed
vsts
Paired with ticket in vsts
Bug Report
Steps
pass a negative value to the pxToRem function
Expected Result
I expect a negative Rem value to be returned
Actual Result
An error is thrown "Invalid value of: …"
Code:
export const pxToRem = (value: number = 0): string => { if (!_htmlFontSizeInPx) { _htmlFontSizeInPx = getComputedFontSize() } if (process.env.NODE_ENV !== 'production') { **if (value < 0) { throw new Error(
Invalid value of: '${value}'.) }** } const convertedValueInRems = value / _htmlFontSizeInPx return
${_.round(convertedValueInRems, 4)}rem}
The text was updated successfully, but these errors were encountered: