Skip to content

Commit

Permalink
Compact multiple adjacent spaces to a single space for consistency in…
Browse files Browse the repository at this point in the history
… character counting among browsers. Fixes #81
  • Loading branch information
kswedberg committed Feb 2, 2014
1 parent 2bc4be3 commit 193125d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions jquery.expander.js
Expand Up @@ -79,8 +79,13 @@
rCloseTag = /<\/(\w+)>/g,
rLastCloseTag = /(<\/[^>]+>)\s*$/,
rTagPlus = /^(<[^>]+>)+.?/,
rMultiSpace = /\s\s+/g,
delayedCollapse;

var removeSpaces = function(str) {
return $.trim( str || '' ).replace(rMultiSpace, ' ');
};

var methods = {
init: function() {
this.each(function() {
Expand All @@ -104,8 +109,8 @@
moreClass = o.moreClass + '',
lessClass = o.lessClass + '',
expandSpeed = o.expandSpeed || 0,
allHtml = $.trim( $this.html() ),
allText = $.trim( $this.text() ),
allHtml = removeSpaces( $this.html() ),
allText = removeSpaces( $this.text() ),
summaryText = allHtml.slice(0, o.slicePoint);

// allow multiple classes for more/less links
Expand Down

0 comments on commit 193125d

Please sign in to comment.