Rename justEmojis to onlyEmoji

This commit is contained in:
Alex Gleason
2021-07-09 16:51:47 -05:00
parent 561c275c60
commit 2082c19c53
4 changed files with 15 additions and 12 deletions

View File

@@ -1,8 +1,9 @@
// Returns `true` if the node contains only emojis, up to a limit
export const justEmojis = (node, limit = 1) => {
export const onlyEmoji = (node, limit = 1) => {
if (!node) return false;
if (node.textContent.replaceAll(' ', '') !== '') return false;
const emojis = [...node.querySelectorAll('img.emojione')];
if (emojis.length === 0) return false;
if (emojis.length > limit) return false;
const images = [...node.querySelectorAll('img')];
if (images.length > emojis.length) return false;