Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

pxToRem() doesn't support negative values #394

Closed
bcalvery opened this issue Oct 23, 2018 · 1 comment
Closed

pxToRem() doesn't support negative values #394

bcalvery opened this issue Oct 23, 2018 · 1 comment
Labels
🧰 bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed vsts Paired with ticket in vsts

Comments

@bcalvery
Copy link
Contributor

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 }

@bcalvery bcalvery added the 🧰 bug Something isn't working label Oct 23, 2018
@levithomason levithomason added help wanted Extra attention is needed good first issue Good for newcomers labels Oct 24, 2018
@pkumarie2011 pkumarie2011 added the vsts Paired with ticket in vsts label Oct 25, 2018
@hughreeling
Copy link
Contributor

hughreeling commented Nov 1, 2018

Closely related to changes in #371. I hope fix will be added to that.

@levithomason levithomason added 🧰 bug Something isn't working and removed 🧰 bug Something isn't working labels Nov 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🧰 bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed vsts Paired with ticket in vsts
Projects
None yet
Development

No branches or pull requests

4 participants