Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/ios emojis #100

Closed
wants to merge 5 commits into from
Closed

Bug/ios emojis #100

wants to merge 5 commits into from

Conversation

brunolm
Copy link

@brunolm brunolm commented May 10, 2018

Fixes #98

Replaced split('') with a for of loop so it doesn't break iOS emoji's on webview.

Some emotes are 2 characters in length, so in a for (const char of chars) char.length will be 2 for most emotes, for a few others they will be followed by a char (code = 65039)

for of + handle 65039 vs old split('').map()

ios-emojis

console.clear();
var str = 'a😂 ☺️ ☠️ 😭a';

var chars = [];
for (const char of str) {
  if (char.charCodeAt(0) === 65039) {
    chars[chars.length - 1] += char;
  }
  else {
    chars.push(char);
  }
}

console.log('for of');
console.log(chars);

console.log('array map');
console.log(str.split('').map(x => x));

Preview

After fix
emojis-preview

Breaking tests

I don't know why the docker tests are not working, but the PR is here in case you want to work on this feature.

@peterhry
Copy link
Owner

peterhry commented May 11, 2018

Thank you for the detailed PR description. I’ve added support for emojis in the latest release.
a710cbb

I ended up using the array spread operator to split the string which handles emojis correctly.

@peterhry peterhry closed this May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Doesn't work with iOS emojis
2 participants