Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/lib/litegraph/src/LGraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ export class LGraphNode
/** @inheritdoc {@link IColorable.setColorOption} */
setColorOption(colorOption: ColorOption | null): void {
if (colorOption == null) {
delete this.color
delete this.bgcolor
this.color = undefined
this.bgcolor = undefined
} else {
this.color = colorOption.color
this.bgcolor = colorOption.bgcolor
Expand Down Expand Up @@ -495,7 +495,7 @@ export class LGraphNode
set shape(v: RenderShape | 'default' | 'box' | 'round' | 'circle' | 'card') {
switch (v) {
case 'default':
delete this._shape
this._shape = undefined
break
case 'box':
this._shape = RenderShape.BOX
Expand Down Expand Up @@ -943,7 +943,7 @@ export class LGraphNode
}

// @ts-expect-error Exceptional case: id is removed so that the graph can assign a new one on add.
delete data.id
data.id = undefined

if (LiteGraph.use_uuids) data.id = LiteGraph.uuidv4()

Expand Down Expand Up @@ -1948,7 +1948,7 @@ export class LGraphNode
for (const input of this.inputs) {
if (input._widget === widget) {
input._widget = undefined
delete input.widget
input.widget = undefined
}
}
}
Expand Down Expand Up @@ -2857,7 +2857,7 @@ export class LGraphNode
const reroutes = LLink.getReroutes(graph, link)
for (const reroute of reroutes) {
reroute.linkIds.add(link.id)
if (reroute.floating) delete reroute.floating
if (reroute.floating) reroute.floating = undefined
reroute._dragging = undefined
}

Expand Down Expand Up @@ -2947,7 +2947,7 @@ export class LGraphNode

reroute.floatingLinkIds.add(link.id)
link.parentId = reroute.id
delete parentReroute.floating
parentReroute.floating = undefined
return reroute
}

Expand Down
14 changes: 6 additions & 8 deletions src/lib/litegraph/src/LGraphNodeProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,12 @@ export class LGraphNodeProperties {
oldValue: any,
newValue: any
): void {
if (oldValue !== newValue && this.node.graph) {
this.node.graph.trigger('node:property:changed', {
nodeId: this.node.id,
property: propertyPath,
oldValue,
newValue
})
}
this.node.graph?.trigger('node:property:changed', {
nodeId: this.node.id,
property: propertyPath,
oldValue,
newValue
})
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests-ui/tests/litegraph/core/LGraphNodeProperties.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ describe('LGraphNodeProperties', () => {
})
})

it("should not emit events when value doesn't change", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we were actually testing for the opposite of what we needed to be doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily, the deletion was the more important breaking piece.

it('should emit event when value is set to the same value', () => {
new LGraphNodeProperties(mockNode)

mockNode.title = 'Test Node' // Same value as original

expect(mockGraph.trigger).toHaveBeenCalledTimes(0)
expect(mockGraph.trigger).toHaveBeenCalledTimes(1)
})

it('should not emit events when node has no graph', () => {
Expand Down