Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
pwfisher committed Nov 1, 2016
1 parent 1ee7f9f commit 55e6f92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions dist/shave.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ function shave(target, maxHeight, opts) {
if (el.offsetHeight < maxHeight) continue;

var fullText = el.textContent;
var words = fullText.split(' ');
if (!spaces) words = el.textContent;
var words = spaces ? fullText.split(' ') : fullText;

// If 0 or 1 words, we're done
if (words.length < 2) continue;

// Binary search for number of words which can fit in allotted height
var max = words.length - 1;
var min = 0;
Expand Down Expand Up @@ -68,4 +69,4 @@ if (plugin) {

return shave;

})));
})));
5 changes: 3 additions & 2 deletions src/shave.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ export default function shave(target, maxHeight, opts) {
if (el.offsetHeight < maxHeight) continue;

const fullText = el.textContent;
let words = fullText.split(' ');
if (!spaces) words = el.textContent;
const words = spaces ? fullText.split(' ') : fullText;

// If 0 or 1 words, we're done
if (words.length < 2) continue;

// Binary search for number of words which can fit in allotted height
let max = words.length - 1;
let min = 0;
Expand Down

0 comments on commit 55e6f92

Please sign in to comment.