almende / vis

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs
7.85k stars 1.48k forks source link

[Network] Error if node.id is a reserved word #4224

Open sunny9528 opened 5 years ago

sunny9528 commented 5 years ago

When I use vis to draw a network, when one of the nodes is named 'constructor', the network displays an error.I checked the IDs of other nodes to confirm that there was no duplication. I want to ask why.Is this constructor the key word?

mojoaxel commented 5 years ago

Is this constructor the key word?

Yes, constructor is a reserved word in javascript. Still there should not be an error!

I connot reproduce this issue: https://jsbin.com/sefefiliqi/edit?html,js,output

sunny9528 commented 5 years ago

When the node ID is'constructor', there will be an error, and lable is no problem

mojoaxel commented 5 years ago

Looks like a bug to me: https://jsbin.com/sefefiliqi/1/edit?html,js,console,output

The documentation for node.id states:

The id of the node. The id is mandatory for nodes and they have to be unique. This should obviously be set per node, not globally

Here is nothing that states the id can not be a reserved word. We should at least fix the documentation.

mojoaxel commented 5 years ago

Workaround for now: Don't use reserved words!

sunny9528 commented 5 years ago

Well, thank you. I see. Thank you very much.