Clamp.js icon indicating copy to clipboard operation
Clamp.js copied to clipboard

internet explorer 8 support

Open alpermutlu opened this issue 10 years ago • 9 comments

Hi all,

I couldn't find any supported browsers information and trying to make it work in ie8. I am getting "Object required" error for "getLastChild" function where "if" begins.

Any help would be appreciated. Thanks

image

alpermutlu avatar Jul 17 '14 13:07 alpermutlu

Seems it doesn't work in IE9 too. Text just disappear. Could anyone confirm this?

pedrofelipe avatar Jul 28 '14 02:07 pedrofelipe

Yes, I can confirm text disappearing in IE9 too. I'm getting following error:

"Unable to get value of the property 'children': object is null or undefined clamp.min.js, line 9 character123"

Any solutions found?

EDIT:

Ok, I found out something that might help:

$clamp(this, {clamp: 4}); // Throws error, text disappears

$clamp(this, {clamp: 'auto'}); // Doesn't throw error, if ran multiple times removes letters at the end one by one

So does this issue have something to do with the paragraph height?

JaakkoKarhu avatar Aug 12 '14 21:08 JaakkoKarhu

I tested it in IE11 and doesn't work too, throw me the same error

iranreyes avatar Dec 19 '14 01:12 iranreyes

I'm having this same issue in a random way all the way from IE8 to IE11. I tried with the {clamp: 'auto'} solution but it only fixed some of the many cases where text is disappearing. Is there any follow up on this issue?

matigon avatar Jan 23 '15 15:01 matigon

For anyone else running into this problem, setting an explicit line-height on the element passed to $clamp resolved the issue for me. I think the issue has to do with the difference in how line-height is reporting in older versions of IE compared to Firefox and Chrome.

In IE8 and IE9 for me, window.getComputedStyle(...).getPropertyValue('line-height') returns the numeric multiplier (e.g. 1.45). In Firefox and Chrome, the same call returns the numeric multiplier * the font-size, which is the actual rendered/visible line-height.

The result is that truncate() will be called recursively and remove chunks because the check on line 186 if (element.clientHeight <= maxHeight) will constantly fail, since maxHeight will be very small.

pbeardshear avatar Jan 28 '15 04:01 pbeardshear

To get it to work in IE11 I added the following to the element containing the text:

display:block;line-height:18px;

No line-height and it rendered 1 line. line-height by itself didn't work.

Hope that helps someone :-)

bythewiseman avatar Apr 24 '15 10:04 bythewiseman

@colinwiseman thank you!

craigdallimore avatar Jul 06 '15 13:07 craigdallimore

@colinwiseman this also fixed it for me (was only showing one line) in IE, thanks

jackappleby avatar Nov 10 '16 13:11 jackappleby

IE11 removed text after '\\ characters

Pumych avatar Jun 10 '18 08:06 Pumych