Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.

Commit a76006d

Browse files
committed
Fix notices not correctly grabbing first emoji
1 parent 3aac02c commit a76006d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

assets/javascripts/discourse/initializers/apply-notice.js.es6

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ function initializeNotice(api) {
55
api.decorateCooked($elem => {
66
$elem.find('blockquote.notice').each(function() {
77
let notice = $(this);
8-
let emoji = notice.children(0).children(0);
8+
let emoji = notice.children(0).children('img.emoji').first();
99
if (emoji.is('img.emoji')) {
1010
let type = emoji.attr('title');
11-
type = type.substring(1, type.length - 1);
12-
notice.removeClass(`only-emoji`);
13-
notice.removeClass(`notice-${type}`);
14-
notice.addClass(`notice-${type}`);
15-
emoji.addClass(`notice-icon`);
11+
if (typeof type === 'string') {
12+
type = type.replace(/^:|:$/gm, '');
13+
notice.removeClass(`notice-${type}`);
14+
notice.addClass(`notice-${type}`);
15+
emoji.removeClass(`only-emoji`);
16+
emoji.addClass(`notice-icon`);
17+
}
1618
}
1719
});
1820
}, { id: "discourse-custom-bbcodes-notice" });

0 commit comments

Comments
 (0)