Skip to content

feat(dia.Graph): add port and magnet options to getConnectedLinks#3404

Merged
kumilingus merged 1 commit into
clientIO:masterfrom
kumilingus:feat/get-connected-links-port-master
Jul 2, 2026
Merged

feat(dia.Graph): add port and magnet options to getConnectedLinks#3404
kumilingus merged 1 commit into
clientIO:masterfrom
kumilingus:feat/get-connected-links-port-master

Conversation

@kumilingus

@kumilingus kumilingus commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What

graph.getConnectedLinks(element, { inbound: true, port: 'xy', magnet: '.body' }) — new port and magnet options that restrict the result to links attached to element at the given port and/or magnet (selector).

Semantics

  • port / magnet match links attached to the queried element at that port / magnet.
  • Matched on the direction-appropriate end: source for outbound, target for inbound. So a self-loop across two ports isn't matched via its other end when only one direction is requested.
  • port and magnet combine with AND; both compose with inbound/outbound. E.g. { inbound: true, port: 'in' } = inbound links landing on in; { outbound: true, port: someInputPort } = [].
  • magnet matches the end's magnet (the joint-selector-based reference). The legacy selector fallback is intentionally not matched.
  • Flows through getNeighbors/getSuccessors/bfs/dfs via ConnectionOptionsExploreOptions.

Implementation

A post-filter on the collected links (single direction-aware end predicate), correct across every flag combination including indirect/deep. Plus port?: string / magnet?: string on Graph.ConnectionOptions and a unit test (direction combos, self-loops, magnet, port+magnet AND, unknown values, no-option unchanged).

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?: string to Graph.ConnectionOptions typings.
  • Implement port filtering in Graph#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 port is 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
@kumilingus kumilingus force-pushed the feat/get-connected-links-port-master branch from 03bdfdf to 100ef6c Compare July 2, 2026 09:16
@kumilingus kumilingus changed the title feat(dia.Graph): add port option to getConnectedLinks feat(dia.Graph): add port and magnet options to getConnectedLinks Jul 2, 2026
@kumilingus kumilingus merged commit 906ddd5 into clientIO:master Jul 2, 2026
3 of 4 checks passed
@kumilingus kumilingus deleted the feat/get-connected-links-port-master branch July 2, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants