This repository was archived by the owner on Mar 4, 2020. It is now read-only.
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
pxToRem() doesn't support negative values #394
Closed
Description
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 }