RadLikeWhoa / Countable

Add live paragraph-, word- and character-counting to an HTML element.
https://sacha.me/Countable
MIT License
1.64k stars 134 forks source link

li element with value 0 causes original.replace() exception #34

Closed paul-muckypuddle closed 8 years ago

paul-muckypuddle commented 9 years ago

When using countable on an li element with a value, the following error occurs (in Chrome):

Uncaught TypeError: original.replace is not a function

Tracing this back it's because the li element value is a number, and obviously the replace function belongs to the string prototype. Adding:

   if(typeof(original) !== 'string'){
        original = "";
   }

around line 177 is a kludgy fix... but not great.

RadLikeWhoa commented 9 years ago

What exactly does the li contain? If it contained a number an easy fix would be to just cast this number to a string.

RadLikeWhoa commented 9 years ago

@paul-muckypuddle Any update on this? An isolated test case would be ideal, because I can't seem to reproduce the error.

paul-muckypuddle commented 9 years ago

My apologies, I found a workaround at the time to get the project I was working on finished. Will review this again and update as soon as possible.

On 14 August 2015 at 13:30, Sacha Schmid notifications@github.com wrote:

@paul-muckypuddle https://github.com/paul-muckypuddle Any update on this? An isolated test case would be ideal, because I can't seem to reproduce the error.

— Reply to this email directly or view it on GitHub https://github.com/RadLikeWhoa/Countable/issues/34#issuecomment-131093154 .

Paul Holmes | Technical Director 0141 847 0095 | paul@muckypuddle.com https://www.facebook.com/muckypuddle https://twitter.com/muckypuddle http://www.pinterest.com/muckypuddle/ http://www.linkedin.com/company/mucky-puddle

RadLikeWhoa commented 8 years ago

This issue is resolved in 097b189.