Use hasOwnProperty to detect if emoji exists

Fixes a bug in Firefox where “watch” emoji would throw because apparently `_emojiData = data.emojis['watch']` returns a function instead of the value of the watch key
release
Etienne Lemay 2016-10-18 19:00:51 -04:00
parent e429147d1f
commit 35a992118a
1 changed files with 9 additions and 10 deletions

View File

@ -36,24 +36,23 @@ function getSanitizedData() {
}
function getData(emoji, skin, sheetURL) {
var emojiData = {},
_emojiData, _emoji, _id
var emojiData = {}
if (typeof emoji == 'string') {
if (_emoji = data.short_names[emoji]) {
emoji = _emoji
if (data.short_names.hasOwnProperty(emoji)) {
emoji = data.short_names[emoji]
}
if (_emojiData = data.emojis[emoji]) {
emojiData = _emojiData
if (data.emojis.hasOwnProperty(emoji)) {
emojiData = data.emojis[emoji]
}
} else if (emoji.id) {
if (_id = data.short_names[emoji.id]) {
emoji.id = _id
if (data.short_names.hasOwnProperty(emoji.id)) {
emoji.id = data.short_names[emoji.id]
}
if (_emojiData = data.emojis[emoji.id]) {
emojiData = _emojiData
if (data.emojis.hasOwnProperty(emoji.id)) {
emojiData = data.emojis[emoji.id]
skin || (skin = emoji.skin)
}
}