Rounding issue in 'getLineHeight' method
Opened this issue · 1 comments
superelement commented
The method getLineHeight
uses parseInt
, which always rounds decimal numbers down. Chrome returns a decimal when calling computeStyle
, which can (in some cases) be something like 23.994
. So in this case Chrome will calculate the value to be 23
, but FF and IE round it up to 24
. This small difference though can mean the difference between lines failing to truncate to the correct number of lines. I propose something like this Math.round(parseFloat(lh))
instead of parseInt(lh)
to give consistent results across browsers.
Tested on Chrome 53.0.2785.116 m (64-bit), FireFox 48.0.2, Microsoft Edge 38.14393.0.0.
superelement commented
I've done a pull request #56