aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaquer <jaquer@users.noreply.github.com>2022-01-29 18:18:36 -0800
committerjaquer <jaquer@users.noreply.github.com>2022-01-29 20:37:29 -0800
commita068a4beb94796b596f423f57cb1e04d637afac6 (patch)
tree9cf702044f600eb364fda83d8cc58e94521749fb
parent3e31ae67d502190dcf34a04b279060fe40c368a8 (diff)
downloadmicroblog-a068a4beb94796b596f423f57cb1e04d637afac6.tar.gz
microblog-a068a4beb94796b596f423f57cb1e04d637afac6.tar.bz2
microblog-a068a4beb94796b596f423f57cb1e04d637afac6.zip
Handle "💩".length === 2 issue.
Stumbled upon the fix via MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length#unicode
-rw-r--r--postform.inc.php3
1 files changed, 1 insertions, 2 deletions
diff --git a/postform.inc.php b/postform.inc.php
index 6749821..d451d63 100644
--- a/postform.inc.php
+++ b/postform.inc.php
@@ -72,8 +72,7 @@
charCount.innerHTML = maxCount;
textarea.addEventListener('input', function() {
- // todo: this should probably respect http://blog.jonnew.com/posts/poo-dot-length-equals-two
- var textLength = this.value.length;
+ var textLength = [...this.value].length;
charCount.innerHTML = maxCount - textLength;
}, false)