Skip to content

Commit

Permalink
Windows (muan#14): Also addressing '--' chars with no unicode equival…
Browse files Browse the repository at this point in the history
…ent, automatically using :name: instead.
  • Loading branch information
patricknelson committed Feb 18, 2017
1 parent 3bb7fd1 commit 89dcd11
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions app/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,18 @@ document.addEventListener('keydown', function (evt) {
})

function copyFocusedEmoji (targetElement, copyText) {
var data, image
var data

// Since focused target could be an image, retarget the parent button.
button = targetElement
if (targetElement.tagName == 'IMG') {
image = targetElement
button = targetElement.parentNode
} else {
// Pull image from first child node instead.
image = targetElement.childNodes[0]
}

// on enter: copy data and exit
if (copyText) {
data = ':' + button.getAttribute('aria-label') + ':'
} else {
data = image.alt
data = button.getAttribute('data-char')
if (copyText || data == '--') {
data = ':' + button.getAttribute('aria-label') + ':'
}
clipboard.writeText(data)
searchInput.value = ''
Expand Down Expand Up @@ -160,6 +156,9 @@ function renderResults (emojiNameArray, containerElement) {
resultElement.className = 'emoji'
resultElement.setAttribute('aria-label', name)

// For consistent retrieval, if no image could be parsed/generated.
resultElement.setAttribute('data-char', unicode)

// Parse the Twitter version of this emoji.
var parsed = twemoji.parse(unicode, function(icon) {
return '../node_modules/twemoji/2/svg/' + icon + '.svg'
Expand Down

0 comments on commit 89dcd11

Please sign in to comment.