Drawflow icon indicating copy to clipboard operation
Drawflow copied to clipboard

node-id v. integer inconsistency?

Open olutmatkaijian opened this issue 2 years ago • 2 comments

Hei,

when I tried to dynamically add Inputs/Outputs onto nodes using drag-and-drop I stumbled upon this issue. When a new node is created, it is created with "node-1" as ID. This works fine for editor.removeNodeId - however, when I tried to call editor.addNodeInput('node-1') it threw an error. Expected behavior would have been for it to add Input.

This is because addNodeInput expects an Integer, while removeNodeId is capable of working with strings.

A quick workaround was to do the following: node_id = node_id.substring(node_id.indexOf("-") + 1); Which seems to work, but I much rather prefer if I did not have to do this.

Other than aforementioned issue I enjoy using this library. Great work.

olutmatkaijian avatar May 29 '22 03:05 olutmatkaijian

I know the problem. The problem comes from older versions and maintain support.

In any case, in the readme, in the examples it is shown.

image You can use this simpler code.

element.id.slice(5)

jerosoler avatar May 29 '22 11:05 jerosoler

It is shown, but it is quite confusing. A "Due to older versions/maintenance support, some functions require an integer instead of a string" or similar in the readme would be useful. Either way thank you.

olutmatkaijian avatar May 29 '22 12:05 olutmatkaijian