Fix up how span elements are generated in message parser

This commit is contained in:
Pavel Djundik 2018-09-05 21:00:39 +03:00
parent ba2522ecda
commit 4f3dbc4b8f

View File

@ -42,17 +42,26 @@ function createFragment(fragment, createElement) {
classes.push("irc-monospace"); classes.push("irc-monospace");
} }
if (classes.length === 0 && !fragment.hexColor) { const data = {};
return fragment.text; let hasData = false;
if (classes.length > 0) {
hasData = true;
data.class = classes;
} }
return createElement("span", { if (fragment.hexColor) {
class: classes, hasData = true;
style: { data.style = {
"color": `#${fragment.hexColor}`, color: `#${fragment.hexColor}`,
"background-color": fragment.hexBgColor ? `#${fragment.hexBgColor}` : null, };
},
}, fragment.text); if (fragment.hexBgColor) {
data.style["background-color"] = `#${fragment.hexBgColor}`;
}
}
return hasData ? createElement("span", data, fragment.text) : fragment.text;
} }
// Transform an IRC message potentially filled with styling control codes, URLs, // Transform an IRC message potentially filled with styling control codes, URLs,