REM-unit-polyfill icon indicating copy to clipboard operation
REM-unit-polyfill copied to clipboard

Values with 4 or more digits and a zero next to the dot do not convert properly

Open timvandevelde opened this issue 9 years ago • 4 comments

My rems are 10px. If I set a width of 80rem it converts nicely to 800px. 101.3rem converts to 1013px. 80.52rem converts to 805px.

But if I set a width of 120.8rem, it converts to 128.8px. 80.50rem converts to 80.5px.

Looks like it has something to do with the zero before the dot.

timvandevelde avatar Jul 03 '15 11:07 timvandevelde

@timvandevelde I'm not able to replicate based on the use case of just the 0 before the dot. e.g.,

html {
    font-size: 10px;
   -webkit-text-size-adjust: 100%;
   -ms-text-size-adjust: 100%;
    line-height: 1.6;
}
.test {
    background-color:black !important;
    color: white;
    width: 50.5rem;
    height: 5em;
}

Will give me:

.test {
  width: 505px;
}

Can you share your project or more specifics?

chuckcarpenter avatar Jul 21 '15 22:07 chuckcarpenter

Have same issue, but in my case also 10.3rem converts to 13px

Bartlomiejsz avatar Nov 23 '15 12:11 Bartlomiejsz

@Bartlomiejsz could you give more info on replicating this use case? I'm not finding any issues w/ the Regex offhand.

chuckcarpenter avatar Jan 04 '16 05:01 chuckcarpenter

@Bartlomiejsz @timvandevelde @chuckcarpenter I had the same issue and was unable to find/fix the bug in the existing code. If you're interested in an alternative solution I wrote one here: https://github.com/nbouvrette/remPolyfill

nbouvrette avatar Jun 09 '17 03:06 nbouvrette