-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rendering an array of nodes is buggy when the Node component's id is set #467
Comments
I believe the ID overrides the Svelvet Node's id attribute, which is used as a unique identifier in an HTML document. I guess the library could warn if multiple components are instantiated with the same ID, however I'd argue it's up to the application to ensure that the IDs are unique. |
Ah, I see. Yes, it's definitely my bad, that I gave every Node the same ID with that 😅 . I think a warning like you said would be nice though, if it's not too much of a hassle. |
I created a code example at https://stackblitz.com/edit/svelvet-v7-zrfaxy?file=src%2Froutes%2F%2Bpage.svelte
There, an array of nodes with random positions is rendered on the canvas when clicking the "new node" button. The problematic code is the
id="55"
bit in line 34. As long as that is there, the deletion of a single node makes all other nodes vanish from the canvas and they only appear again once a new node is added. Removing theid="55"
bit fixes the bug.I stumbled upon this because I copied the code example from https://svelvet.mintlify.app/components/node and forgot to delete the
id="55"
bit. Is it possible to avoid that bug for others in the future by e.g. issuing a warning on the command line in situations like these?The text was updated successfully, but these errors were encountered: