[CodeHealth] Standardise code (#951)

Refactors & standardises code.
This commit is contained in:
filtered
2025-04-21 01:02:54 +10:00
committed by GitHub
parent 7c236bcfc8
commit f7a0a92f3a
4 changed files with 26 additions and 23 deletions

View File

@@ -1472,7 +1472,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
*/
addInput(name: string, type: ISlotType, extra_info?: Partial<INodeInputSlot>): INodeInputSlot {
type = type || 0
const input: INodeInputSlot = new NodeInputSlot({ name: name, type: type, link: null })
const input = new NodeInputSlot({ name: name, type: type, link: null })
if (extra_info) Object.assign(input, extra_info)
this.inputs ||= []
@@ -2878,10 +2878,9 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
* @internal The inputs that are not positioned with absolute coordinates.
*/
get #defaultVerticalInputs() {
return this.inputs.filter((slot: INodeInputSlot) => !(
slot.pos ||
(this.widgets?.length && isWidgetInputSlot(slot))
))
return this.inputs.filter(
slot => !slot.pos && !(this.widgets?.length && isWidgetInputSlot(slot)),
)
}
/**
@@ -3489,7 +3488,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
slots.push(layoutElement)
}
return slots.length ? createBounds(slots, /** padding= */ 0) : null
return slots.length ? createBounds(slots, 0) : null
}
#getMouseOverSlot(slot: INodeSlot): INodeSlot | null {
@@ -3658,7 +3657,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
for (const [i, slot] of this.inputs.entries()) {
if (!isWidgetInputSlot(slot)) continue
slotByWidgetName.set(slot.widget?.name, { ...slot, index: i })
slotByWidgetName.set(slot.widget.name, { ...slot, index: i })
}
if (!slotByWidgetName.size) return