diff --git a/app/assets/javascripts/discourse/lib/emoji/emoji.js.erb b/app/assets/javascripts/discourse/lib/emoji/emoji.js.erb
index e662df804..8a8fceb25 100644
--- a/app/assets/javascripts/discourse/lib/emoji/emoji.js.erb
+++ b/app/assets/javascripts/discourse/lib/emoji/emoji.js.erb
@@ -77,7 +77,8 @@ function imageFor(code) {
code = code.toLowerCase();
var url = urlFor(code);
if (url) {
- return ['img', { href: url, title: ':' + code + ':', 'class': 'emoji', alt: code }];
+ var code = ':' + code + ':';
+ return ['img', { href: url, title: code, 'class': 'emoji', alt: code }];
}
}
diff --git a/test/javascripts/lib/bbcode-test.js.es6 b/test/javascripts/lib/bbcode-test.js.es6
index 575ad7e75..385569c9c 100644
--- a/test/javascripts/lib/bbcode-test.js.es6
+++ b/test/javascripts/lib/bbcode-test.js.es6
@@ -52,7 +52,7 @@ test('spoiler', function() {
format("[spoiler]it's a sled[/spoiler]", "it's a sled", "supports spoiler tags on text");
format("[spoiler][/spoiler]",
"", "supports spoiler tags on images");
- format("[spoiler] This is the **bold** :smiley: [/spoiler]", " This is the bold ", "supports spoiler tags on emojis");
+ format("[spoiler] This is the **bold** :smiley: [/spoiler]", " This is the bold ", "supports spoiler tags on emojis");
format("[spoiler] Why not both ?[/spoiler]", " Why not both ?", "supports images and text");
format("In a p tag a spoiler [spoiler] [/spoiler] can work.", "In a p tag a spoiler can work.", "supports images and text in a p tag");
});