Skip to content

Commit b4413e7

Browse files
[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 <[email protected]>
1 parent 34d026a commit b4413e7

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

src/lib/litegraph/src/LGraphNode.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -332,39 +332,14 @@ export class LGraphNode
332332

333333
/** @inheritdoc {@link IColorable.setColorOption} */
334334
setColorOption(colorOption: ColorOption | null): void {
335-
const oldColor = this.color
336-
const oldBgcolor = this.bgcolor
337-
338335
if (colorOption == null) {
339336
delete this.color
340337
delete this.bgcolor
341338
} else {
342339
this.color = colorOption.color
343340
this.bgcolor = colorOption.bgcolor
344341
}
345-
346-
// Trigger property change events for Vue node synchronization
347-
if (this.graph) {
348-
const newColor = this.color // undefined if deleted
349-
const newBgcolor = this.bgcolor // undefined if deleted
350-
351-
if (oldColor !== newColor) {
352-
this.graph.trigger('node:property:changed', {
353-
nodeId: this.id,
354-
property: 'color',
355-
oldValue: oldColor,
356-
newValue: newColor
357-
})
358-
}
359-
if (oldBgcolor !== newBgcolor) {
360-
this.graph.trigger('node:property:changed', {
361-
nodeId: this.id,
362-
property: 'bgcolor',
363-
oldValue: oldBgcolor,
364-
newValue: newBgcolor
365-
})
366-
}
367-
}
342+
// Property change events are now handled automatically by LGraphNodeProperties instrumentation
368343
}
369344

370345
/** @inheritdoc {@link IColorable.getColorOption} */

src/lib/litegraph/src/LGraphNodeProperties.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import type { LGraphNode } from './LGraphNode'
66
const DEFAULT_TRACKED_PROPERTIES: string[] = [
77
'title',
88
'flags.collapsed',
9-
'mode'
9+
'mode',
10+
'color',
11+
'bgcolor'
1012
]
1113

1214
/**

0 commit comments

Comments
 (0)