Skip to content

Commit c1f2834

Browse files
authored
Merge pull request #20 from github/connect-without-tone
Update skin tone only when tone attribute exists
2 parents db9bf81 + 8a6c986 commit c1f2834

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ class GEmojiElement extends HTMLElement {
3535
image.src = this.getAttribute('fallback-src') || ''
3636
this.appendChild(image)
3737
}
38-
updateTone(this)
38+
39+
if (this.hasAttribute('tone')) {
40+
updateTone(this)
41+
}
3942
}
4043

4144
static get observedAttributes(): Array<string> {

test/test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ describe('g-emoji', function() {
2929
assert.equal('G-EMOJI', el.nodeName)
3030
assert.equal('👋🏻', el.textContent)
3131
})
32+
33+
it('does not change skin tone when connected without tone attribute', function() {
34+
const el = new window.GEmojiElement()
35+
el.textContent = '👋🏻'
36+
document.body.append(el)
37+
assert.equal('G-EMOJI', el.nodeName)
38+
assert.equal('👋🏻', el.textContent)
39+
})
3240
})
3341

3442
describe('in emoji-supporting platforms', function() {

0 commit comments

Comments
 (0)