fix: scope edge movement to current graph
Summary
Fixes #513.
Edges were being moved with document.querySelector('.svelvet-graph-wrapper'), which always returns the first Svelvet graph wrapper on the page. In pages with multiple Svelvet instances, that caused edges from later instances to be appended into the first graph.
This changes edge movement to use edgeElement.closest('.svelvet-graph-wrapper'), so each edge is appended to the graph wrapper it was rendered inside. It also avoids removing the edge when it is already parented by the correct wrapper.
Test coverage
Added a jsdom unit test that builds two .svelvet-graph-wrapper containers and verifies an edge from the second wrapper stays under that second wrapper instead of moving to the first one.
Validation
npm run test:unit -- tests/unit-tests/components/edgeMove.test.tsnpm run test:unitnpx prettier --check src/lib/components/Edge/Edge.svelte tests/unit-tests/components/edgeMove.test.tsnpx eslint src/lib/components/Edge/Edge.svelte tests/unit-tests/components/edgeMove.test.tsnpm run build
Known existing failure:
npm run checkstill reports the existing repo-wide 64 errors / 5 warnings in unrelated files such asDrawerController.svelte,createGraph.ts, route examples, and existing tests.
Sphinx bounty #2284 payout address: bc1qev5ant33v5y89qqjvcf4mh9hlax5svqf5xd7gc.
Current-head validation rerun on 88b58e5f4cfdcec9074c6a9632ec6d5d008e1d3d:
git diff --check origin/main...HEADnpm run test:unit -- tests/unit-tests/components/edgeMove.test.ts(1 test passed)npm run test:unit(5 suites / 10 tests passed)npx prettier --check src/lib/components/Edge/Edge.svelte tests/unit-tests/components/edgeMove.test.tsnpx eslint src/lib/components/Edge/Edge.svelte tests/unit-tests/components/edgeMove.test.tsnpm run build(build/package/publint completed; existing route a11y/unused CSS warnings only)
Local worktree is clean after the rerun.