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

ignoreReturns: true not respected #64

Open smileBeda opened 3 years ago

smileBeda commented 3 years ago

The default implementation of below does not respect the ignoreReturns: true:

$( window ).on('load', function() {
    Countable.on( 
        document.getElementById('my_area'), 
        counter => console.log(counter),
        {
            ignoreReturns: true
        }
    )  
});

Doing so, the all property still counts returns (enter/newline)

Thus, we always get a wrong character count when doing this:

$( window ).on('load', function() {
    Countable.on( 
        document.getElementById('my_area'), 
        counter => document.getElementById('my_result').innerHTML = counter.all.toString(),
        {
            ignoreReturns: true
        }
    )  
});

The doc clearly states that we shall use that option to Ignore returns when calculating the all property.

Suggestions?