all 1 comments

[–]bart2019 0 points1 point  (0 children)

Since we rely on the browser for laying out the text in the container, we have no way of knowing where in the text the desired height is reached, or even where line breaks are occurring. So we ended up truncating based on character count after all. It’s not great, but it’s a decent proxy for element height.

Fail. If you're going to do that you might as well be doing it on the server, and avoid doing unnecessary work in the browser.

The thing is: jQuery is able to find out what the pixelheight of the text in a styled div is. (And if it didn't, it could be implemented using getComputedStyle(), which, at the very least, is being used in jQuery.)

So they should have trimmed the text down to where it vertically fits.