Skip to content

Commit

Permalink
Fix clamping for nested elements by ensuring that some core function …
Browse files Browse the repository at this point in the history
…is always called with an Array, not a NodeList
  • Loading branch information
makmic committed Oct 23, 2019
1 parent a179a5a commit ec85d09
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dist/superclamp.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/*!
* Superclamp 0.2.1
* Superclamp 0.2.2
* https://github.com/makandra/superclamp
*/

Expand Down Expand Up @@ -413,7 +413,7 @@
};

getContents = function(node) {
return node.childNodes;
return Array.prototype.slice.call(node.childNodes);
};

hideAll = function(nodes) {
Expand Down
4 changes: 2 additions & 2 deletions dist/superclamp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superclamp",
"version": "0.2.1",
"version": "0.2.2",
"description": "Cross-browser ellipsis for multi-line texts, optimized for performance. No dependencies.",
"main": "dist/superclamp.js",
"files": [
Expand Down
4 changes: 2 additions & 2 deletions src/superclamp.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###!
* Superclamp 0.2.1
* Superclamp 0.2.2
* https://github.com/makandra/superclamp
###

Expand Down Expand Up @@ -335,7 +335,7 @@ initializeTextNode = (textNode) ->
return

getContents = (node) ->
node.childNodes
Array.prototype.slice.call(node.childNodes)

hideAll = (nodes) ->
debug 'hideAll', nodes
Expand Down
10 changes: 10 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ <h2>Container including paragraphs (KNOWN ISSUE: ellipsis will be outside of par
Etiam in nisl sed lorem venenatis cursus. Morbi ultrices interdum ipsum, non viverra tellus dictum non. Fusce vitae lacinia purus. Vestibulum eu libero eget odio venenatis malesuada. Nulla ligula purus, facilisis vel venenatis vel, ornare euismod lorem. Sed lacinia fermentum sem, quis posuere urna aliquam non. Fusce et sagittis mauris, non lacinia metus.
</p>
</div>
<h2>Container including nested elements</h2>
<div class="clamp-me">
<div class="nested-container">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam gravida sem quam, a pulvinar diam mattis at. Fusce sit amet tortor nibh. Nunc vel augue scelerisque, blandit nunc in, ornare diam. Phasellus egestas venenatis ligula, a imperdiet libero pretium non. Etiam id urna ut eros rutrum varius. Donec sit amet ligula blandit, tincidunt massa id, rhoncus eros. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
</p><p>
Quisque hendrerit turpis sit amet enim auctor, sed posuere libero hendrerit. In ante justo, dignissim eget sapien eu, interdum pulvinar erat. Vestibulum non fermentum mi, ut convallis libero.
</p>
</div>
</div>
<!--
<h2>Many more elements to be clamped, to reveal performance issues</h2>
<div class="clamp-me">
Expand Down

0 comments on commit ec85d09

Please sign in to comment.