From 0491007c0f73fac91781022a02b7301aa84e0877 Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 25 Sep 2025 15:56:55 -0700 Subject: [PATCH] [refactor] use LGraphNodeProperties for color property tracking - addresses review feedback Moves color and bgcolor property change tracking to the standard LGraphNodeProperties system instead of manual event firing in setColorOption. This reduces custom code and leverages the existing property instrumentation infrastructure. Co-authored-by: DrJKL --- src/lib/litegraph/src/LGraphNode.ts | 27 +------------------ src/lib/litegraph/src/LGraphNodeProperties.ts | 4 ++- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/lib/litegraph/src/LGraphNode.ts b/src/lib/litegraph/src/LGraphNode.ts index f01e4f761..320820d12 100644 --- a/src/lib/litegraph/src/LGraphNode.ts +++ b/src/lib/litegraph/src/LGraphNode.ts @@ -332,9 +332,6 @@ export class LGraphNode /** @inheritdoc {@link IColorable.setColorOption} */ setColorOption(colorOption: ColorOption | null): void { - const oldColor = this.color - const oldBgcolor = this.bgcolor - if (colorOption == null) { delete this.color delete this.bgcolor @@ -342,29 +339,7 @@ export class LGraphNode this.color = colorOption.color this.bgcolor = colorOption.bgcolor } - - // Trigger property change events for Vue node synchronization - if (this.graph) { - const newColor = this.color // undefined if deleted - const newBgcolor = this.bgcolor // undefined if deleted - - if (oldColor !== newColor) { - this.graph.trigger('node:property:changed', { - nodeId: this.id, - property: 'color', - oldValue: oldColor, - newValue: newColor - }) - } - if (oldBgcolor !== newBgcolor) { - this.graph.trigger('node:property:changed', { - nodeId: this.id, - property: 'bgcolor', - oldValue: oldBgcolor, - newValue: newBgcolor - }) - } - } + // Property change events are now handled automatically by LGraphNodeProperties instrumentation } /** @inheritdoc {@link IColorable.getColorOption} */ diff --git a/src/lib/litegraph/src/LGraphNodeProperties.ts b/src/lib/litegraph/src/LGraphNodeProperties.ts index 271d98e1e..f4a5d0c13 100644 --- a/src/lib/litegraph/src/LGraphNodeProperties.ts +++ b/src/lib/litegraph/src/LGraphNodeProperties.ts @@ -7,7 +7,9 @@ const DEFAULT_TRACKED_PROPERTIES: string[] = [ 'title', 'flags.collapsed', 'flags.pinned', - 'mode' + 'mode', + 'color', + 'bgcolor' ] /**