Skip to content
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
@bcalvery

Description

@bcalvery

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 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomershelp wantedExtra attention is neededvstsPaired with ticket in vsts🧰 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions