Skip to content

Commit

Permalink
Fixed esamattis#72, allowing prune to run on IE8
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiokas committed Dec 26, 2011
1 parent 0073f37 commit f06a71c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/underscore.string.js
Expand Up @@ -333,15 +333,17 @@
var template = '';
var pruned = '';
var i = 0;
var chars = []; // IE8 fix

// Set default values
pruneStr = pruneStr || '...';
length = parseNumber(length);

// Convert to an ASCII string to avoid problems with unicode chars.
for (i in str) {
template += (isWordChar(str[i]))?'A':' ';
}
chars = _s.chars(str); // IE8 fix to allow iteration over the source string
for (i in chars) {
template += (isWordChar(chars[i]))?'A':' ';
}

// Check if we're in the middle of a word
if( template.substring(length-1, length+1).search(/^\w\w$/) === 0 )
Expand Down

0 comments on commit f06a71c

Please sign in to comment.