Skip to content

Commit 0feec81

Browse files
committed
Improve node addition and layout options handling
Updated addNode to support explicit nodeUID and handle string attributes. Replaced structuredClone with object spread for layoutOptions in BuildGraphData for better compatibility.
1 parent 50d94bf commit 0feec81

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

plugins/graph/graph/node/AddNodeMethods.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@ import GetGraphItem from '../../graphitem/GetGraphItem.js';
22
import GetObjUID from '../../graphitem/GetObjUID.js';
33

44
export default {
5-
addNode(gameObejct, attributes) {
5+
addNode(gameObejct, attributes, nodeUID) {
66
if (this.isNode(gameObejct)) {
77
return this;
88
}
99

10+
if (typeof (attributes) === 'string') {
11+
nodeUID = attributes;
12+
attributes = undefined;
13+
}
14+
1015
GetGraphItem(gameObejct).setGraph(this);
1116

12-
var nodeUID = GetObjUID(gameObejct);
17+
if (nodeUID === undefined) {
18+
nodeUID = GetObjUID(gameObejct);
19+
}
20+
1321
this.graph.addNode(nodeUID, attributes);
1422

1523
return this;

plugins/graph/layout/elkjs/BuildGraphData.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var BuildGraphData = function (graph, config) {
1818
id: uid, width: width, height: height
1919
};
2020
if (attributes.hasOwnProperty('layoutOptions')) {
21-
nodeData.layoutOptions = structuredClone(attributes.layoutOptions);
21+
nodeData.layoutOptions = { ...attributes.layoutOptions };
2222
}
2323
nodes.push(nodeData);
2424

0 commit comments

Comments
 (0)