From 1a06c91ed179b02ca9d6656c3ae1bda5d66b816a Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Mon, 10 Feb 2025 22:06:20 -0500 Subject: [PATCH] [BugFix] Workaround custom nodes expectation on DOMWidget.value (#2505) --- src/scripts/domWidget.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/scripts/domWidget.ts b/src/scripts/domWidget.ts index fed60f38be..fc17709cd6 100644 --- a/src/scripts/domWidget.ts +++ b/src/scripts/domWidget.ts @@ -439,6 +439,18 @@ LGraphNode.prototype.addDOMWidget = function < } const widget = new DOMWidgetImpl(name, type, element, options) + // Workaround for https://github.com/Comfy-Org/ComfyUI_frontend/issues/2493 + // Some custom nodes are explicitly expecting getter and setter of `value` + // property to be on instance instead of prototype. + Object.defineProperty(widget, 'value', { + get(this: DOMWidgetImpl): V { + return this.options.getValue?.() ?? ('' as V) + }, + set(this: DOMWidgetImpl, v: V) { + this.options.setValue?.(v) + this.callback?.(this.value) + } + }) // Ensure selectOn exists before iteration const selectEvents = options.selectOn ?? ['focus', 'click']