[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 <DrJKL@users.noreply.github.com>
This commit is contained in:
bymyself
2025-09-25 15:56:55 -07:00
parent 022e069a17
commit 0491007c0f
2 changed files with 4 additions and 27 deletions

View File

@@ -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} */

View File

@@ -7,7 +7,9 @@ const DEFAULT_TRACKED_PROPERTIES: string[] = [
'title',
'flags.collapsed',
'flags.pinned',
'mode'
'mode',
'color',
'bgcolor'
]
/**