Fix progress bar context menu title showing raw HTML on newer frontends
Newer ComfyUI frontends render the ContextMenu title via textContent instead of innerHTML (XSS hardening), so the HTML string passed as the progress bar menu title was displayed as raw markup. Pass a plain-text title and swap in the logo markup after the menu is created.
This commit is contained in:
@@ -320,11 +320,18 @@ class Rgthree extends EventTarget {
|
||||
LiteGraph.closeAllContextMenus();
|
||||
if (e.button == 2) {
|
||||
const canvas = await waitForCanvas();
|
||||
new LiteGraph.ContextMenu(this.getRgthreeIContextMenuValues(), {
|
||||
title: `<div class="rgthree-contextmenu-item rgthree-contextmenu-title-rgthree-comfy">${logoRgthree} rgthree-comfy</div>`,
|
||||
// Newer ComfyUI frontends render the ContextMenu title with textContent (no HTML
|
||||
// parsing), which would show an HTML title as raw markup. Pass a plain-text title,
|
||||
// then swap in our logo markup afterwards.
|
||||
const menu = new LiteGraph.ContextMenu(this.getRgthreeIContextMenuValues(), {
|
||||
title: "rgthree-comfy",
|
||||
left: e.clientX,
|
||||
top: 5,
|
||||
});
|
||||
const titleEl = query<HTMLDivElement>(".litemenu-title", menu.root);
|
||||
if (titleEl) {
|
||||
titleEl.innerHTML = `<div class="rgthree-contextmenu-item rgthree-contextmenu-title-rgthree-comfy">${logoRgthree} rgthree-comfy</div>`;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (e.button == 0) {
|
||||
|
||||
@@ -188,11 +188,15 @@ class Rgthree extends EventTarget {
|
||||
LiteGraph.closeAllContextMenus();
|
||||
if (e.button == 2) {
|
||||
const canvas = await waitForCanvas();
|
||||
new LiteGraph.ContextMenu(this.getRgthreeIContextMenuValues(), {
|
||||
title: `<div class="rgthree-contextmenu-item rgthree-contextmenu-title-rgthree-comfy">${logoRgthree} rgthree-comfy</div>`,
|
||||
const menu = new LiteGraph.ContextMenu(this.getRgthreeIContextMenuValues(), {
|
||||
title: "rgthree-comfy",
|
||||
left: e.clientX,
|
||||
top: 5,
|
||||
});
|
||||
const titleEl = query(".litemenu-title", menu.root);
|
||||
if (titleEl) {
|
||||
titleEl.innerHTML = `<div class="rgthree-contextmenu-item rgthree-contextmenu-title-rgthree-comfy">${logoRgthree} rgthree-comfy</div>`;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (e.button == 0) {
|
||||
|
||||
Reference in New Issue
Block a user