You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah, ran into the same issue. At least in my case, the only way clamp.js has worked for us is with useNativeClamp: true (which is the default), on the browsers where webkit-line-clamp is supported.
i.e. it's not working for us, unfortunately, with the same error as above. Don't have time to dig in right now, but may come back to this if possible; it's a bit tricky to figure out where things might be off without some specs in place. Obviously, the library has been around for a long time with plenty of people getting benefit out of it, so maybe it's something different in our setup 🤔
The issue occurs because the library keeps removing all the children until none are left.
If you take a closer look at the condition in https://github.com/josephschmitt/Clamp.js/blob/master/clamp.js#L121
You will see that it decides whether to remove the element if the children's nodeValue is falsy.
However, element nodes don't ever have a value of their own, so the script thinks they are empty.
For example, lets say you have the following where we only want to display the first line.
<divclass="clamp"><p>I am the first line of text.</p><p>I am the second line of text.</p></div>
The getLastChild function checks the nodeValue of the paragraphs which return null because there is another node in them (the text node) that contains the text.
Solution
Unfortunately you need to modify the source code, by replacing all nodeValue accessors with textContent.
So elem.lastChild.nodeValue should be elem.lastChild.textContent.
Hello,
i like this plugin but now i have a first conflict that i can not solved :(
I use jq owlCarousel and on this section have clamp.js problems :(
This error is only on browsers without webkitLineClamp
I hope any can help me to fix :(
The text was updated successfully, but these errors were encountered: