feat(dia.Graph): add port and magnet options to getConnectedLinks#3404
Merged
kumilingus merged 1 commit intoJul 2, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a port filter option to dia.Graph#getConnectedLinks so callers can restrict connected-link results to those attached to a specific port on the queried element; this also propagates through traversal helpers that forward ConnectionOptions.
Changes:
- Add
port?: stringtoGraph.ConnectionOptionstypings. - Implement
portfiltering inGraph#getConnectedLinks()via a direction-aware post-filter (source for outbound, target for inbound). - Add a QUnit unit test covering direction combinations, self-loop across ports, missing port, and unchanged behavior when
portis omitted.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/joint-core/types/dia.d.ts | Extends Graph.ConnectionOptions with the new port option (typed and documented). |
| packages/joint-core/src/dia/Graph.mjs | Applies a direction-aware port post-filter to the collected connected links before returning. |
| packages/joint-core/test/jointjs/graph.js | Adds coverage for the port option behavior across inbound/outbound and self-loop scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
`graph.getConnectedLinks(element, { inbound: true, port: 'xy', magnet: '.body' })`
restricts the result to links attached to the element at the given port and/or
magnet (selector). Both are matched on the direction-appropriate end (source for
outbound, target for inbound), so a self-loop isn't matched via its other end
when only one direction is requested. `port` and `magnet` combine with AND, and
compose with the existing inbound/outbound flags.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SYaFvnrAk29uu4UdjwoAdK
03bdfdf to
100ef6c
Compare
port option to getConnectedLinksport and magnet options to getConnectedLinks
zbynekstara
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
graph.getConnectedLinks(element, { inbound: true, port: 'xy', magnet: '.body' })— newportandmagnetoptions that restrict the result to links attached toelementat the given port and/or magnet (selector).Semantics
port/magnetmatch links attached to the queried element at that port / magnet.portandmagnetcombine with AND; both compose withinbound/outbound. E.g.{ inbound: true, port: 'in' }= inbound links landing onin;{ outbound: true, port: someInputPort }=[].magnetmatches the end'smagnet(thejoint-selector-based reference). The legacyselectorfallback is intentionally not matched.getNeighbors/getSuccessors/bfs/dfsviaConnectionOptions→ExploreOptions.Implementation
A post-filter on the collected links (single direction-aware end predicate), correct across every flag combination including
indirect/deep. Plusport?: string/magnet?: stringonGraph.ConnectionOptionsand a unit test (direction combos, self-loops, magnet, port+magnet AND, unknown values, no-option unchanged).🤖 Generated with Claude Code