[refactor] Remove parentSubgraphNode property from widgets (#1145)

This commit is contained in:
Christian Byrne
2025-07-21 11:26:03 -07:00
committed by GitHub
parent efdb8080ae
commit def6010d72
4 changed files with 4 additions and 55 deletions

View File

@@ -190,9 +190,6 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
// Use the first matching widget
const promotedWidget = toConcreteWidget(widget, this).createCopyForNode(this)
// Set parentSubgraphNode for all promoted widgets to track their origin
promotedWidget.parentSubgraphNode = this
Object.assign(promotedWidget, {
get name() {
return subgraphInput.name
@@ -332,7 +329,6 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
override onRemoved(): void {
// Clean up all promoted widgets
for (const widget of this.widgets) {
widget.parentSubgraphNode = undefined
this.subgraph.events.dispatch("widget-demoted", { widget, subgraphNode: this })
}

View File

@@ -1,7 +1,6 @@
import type { CanvasColour, Point, RequiredProps, Size } from "../interfaces"
import type { CanvasPointer, LGraphCanvas, LGraphNode } from "../litegraph"
import type { CanvasPointerEvent } from "./events"
import type { NodeLike } from "./NodeLike"
export interface IWidgetOptions<TValues = unknown[]> {
on?: string
@@ -202,14 +201,6 @@ export interface IBaseWidget<
tooltip?: string
/**
* Reference to the subgraph container node when this widget is promoted from a subgraph.
* This allows the widget to know which SubgraphNode it belongs to in the parent graph.
* @remarks This property is a runtime reference and should not be serialized.
* It will be undefined after deserialization and needs to be reconstructed.
*/
parentSubgraphNode?: NodeLike
// TODO: Confirm this format
callback?(
value: any,

View File

@@ -1,7 +1,6 @@
import type { Point } from "@/interfaces"
import type { CanvasPointer, LGraphCanvas, LGraphNode, Size } from "@/litegraph"
import type { CanvasPointerEvent } from "@/types/events"
import type { NodeLike } from "@/types/NodeLike"
import type { IBaseWidget } from "@/types/widgets"
import { drawTextInArea } from "@/draw"
@@ -57,12 +56,6 @@ export abstract class BaseWidget<TWidget extends IBaseWidget = IBaseWidget> impl
return this.#node
}
/**
* Reference to the subgraph container node when this widget is promoted from a subgraph.
* This allows the widget to know which SubgraphNode it belongs to in the parent graph.
*/
parentSubgraphNode?: NodeLike
linkedWidgets?: IBaseWidget[]
name: string
options: TWidget["options"]