Fix up how span elements are generated in message parser
This commit is contained in:
parent
ba2522ecda
commit
4f3dbc4b8f
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user