Clamp.js
Clamp.js copied to clipboard
internet explorer 8 support
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
Seems it doesn't work in IE9 too. Text just disappear. Could anyone confirm this?
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?
I tested it in IE11 and doesn't work too, throw me the same error
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?
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.
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 :-)
@colinwiseman thank you!
@colinwiseman this also fixed it for me (was only showing one line) in IE, thanks
IE11 removed text after '\\ characters