added property to Emoji class to be used for pattern matching purposes
This is to fix issues #485 and #484. I added a new property for Emoji for pattern matching purposes. The issue was that whenever the emoji has more than one code point, EmojiUtils.isOnlyEmojis() doesn't work.
@vanniktech if it works and it's better than what we currently have, why not? :)
@rubengees poke here again :P
@tricksilver04 I've added test for this: https://github.com/vanniktech/Emoji/pull/578
I tried your changes locally and unignored the test, however it's failing for the red emoji heart. Can you please have another look?
@vanniktech I debugged this a bit and have the following findings:
- Some emojis can optionally have a variant selector which denotes the previous emoji to be rendered as an emoji instead of text. We have multiple emojis that can have this variant selector.
- Our datasource includes information about this. If the emoji can have a variant selector, the
non_qualifiedfield is notnull. I tried to extend the generator to take this into account and made the tests pass except for the red heart exclamation. - I saw that we already specifically handle the star emoji with a variant selector. Interestingly that emoji does not appear in our data source as such a case.
- The red heart exclamation seems to be either invalid or a special case. The code points are [10083, 65039, 65039] or
2763-FE0F-FE0Fin hex.2763-FE0Fwould be the heart exclamation with variant selector, but as we can see it has an additional variant selector! I'm not sure if multiple variant selectors are valid but e.g. browsers seem to ignore the second one.
I can think of two solutions:
- Strip all variant selectors from the text before processing it in either the utils or when rendering the images. We want to display everything as an emoji either way.
- Extend the generator to include this information in our code and handle it accordingly. Weird cases like the double variant selector would not work properly though I think.
I saw that we already specifically handle the star emoji with a variant selector.
Yes if I remember correctly, we've had a report about this in the past and did a fix for it. (without thinking about all of the other emojis like described here)
Can we do a mix that we adjust the generator to include the information and just get rid of the double variant selector ourself?
@rubengees I just saw this
https://github.com/vanniktech/Emoji/blob/b1155d5146237d7c6e60734734a861eea10ce645/generator/index.js#L248
This is where we handle the star