Skip to content

Commit

Permalink
Fix issue and bump version to 1.1.1 (#24)
Browse files Browse the repository at this point in the history
Fix issue #23, when update is called with an empty string, the content is not updated with an empty string
  • Loading branch information
Tuizi committed May 5, 2016
1 parent 35f5189 commit 13191e8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/truncate.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@

// Update HTML if provided, otherwise use the current html and restore
// the truncated content to the original if it's currently present.
if (html) {
if (typeof html !== 'undefined') {
this.original = this.element.innerHTML = html;
} else if (this.isCollapsed && this.element.innerHTML === this.cached) {
this.element.innerHTML = this.original;
Expand Down
2 changes: 1 addition & 1 deletion dist/truncate.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": "truncate.js",
"version": "1.1.0",
"version": "1.1.1",
"description": "Fast, intelligent Javascript text truncation",
"author": "Jeff Chan",
"contributors": [{
Expand Down
6 changes: 6 additions & 0 deletions test/chrome/truncate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ describe('truncate.js', function () {
this.$fixture.truncate('update');
assert.equal(this.$fixture.html(), "<div>Members, friends, adversaries… <a href=\"#\">More</a></div>");
});

it('should support empty string', function () {
this.$fixture.html("<div>Members, friends, adversaries, competitors, and colleagues</div>");
this.$fixture.truncate('update', "");
assert.equal(this.$fixture.html(), "");
});
});

describe('.expand()', function () {
Expand Down
6 changes: 6 additions & 0 deletions test/phantomjs/truncate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ describe('truncate.js', function () {
this.$fixture.truncate('update');
assert.equal(this.$fixture.html(), "<div>Members, friends, adversaries,… <a href=\"#\">More</a></div>");
});

it('should support empty string', function () {
this.$fixture.html("<div>Members, friends, adversaries, competitors, and colleagues</div>");
this.$fixture.truncate('update', "");
assert.equal(this.$fixture.html(), "");
});
});

describe('.expand()', function () {
Expand Down
2 changes: 1 addition & 1 deletion truncate.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@

// Update HTML if provided, otherwise use the current html and restore
// the truncated content to the original if it's currently present.
if (html) {
if (typeof html !== 'undefined') {
this.original = this.element.innerHTML = html;
} else if (this.isCollapsed && this.element.innerHTML === this.cached) {
this.element.innerHTML = this.original;
Expand Down

0 comments on commit 13191e8

Please sign in to comment.