Skip to content

Commit a43c993

Browse files
committed
Fix bug where truncation calculation was off when submitting truncationHTML.
1 parent 9d8e6a8 commit a43c993

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

clamp.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Clamp.js 0.5
2+
* Clamp.js 0.5.1
33
*
44
* Copyright 2011-2013, Joseph Schmitt http://joe.sh
55
* Released under the WTFPL license
@@ -146,10 +146,6 @@
146146
}
147147

148148
var nodeValue = target.nodeValue.replace(opt.truncationChar, '');
149-
if (truncationHTMLContainer) {
150-
target.nodeValue = target.nodeValue.replace(opt.truncationChar, '');
151-
element.innerHTML = target.nodeValue + ' ' + truncationHTMLContainer.innerHTML + opt.truncationChar;
152-
}
153149

154150
//Grab the next chunks
155151
if (!chunks) {
@@ -177,6 +173,12 @@
177173
else {
178174
chunks = null;
179175
}
176+
177+
//Insert the custom HTML before the truncation character
178+
if (truncationHTMLContainer) {
179+
target.nodeValue = target.nodeValue.replace(opt.truncationChar, '');
180+
element.innerHTML = target.nodeValue + ' ' + truncationHTMLContainer.innerHTML + opt.truncationChar;
181+
}
180182

181183
//Search produced valid chunks
182184
if (chunks) {

clamp.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)