fix(dia.HighlighterView): prevent highlighting nodes outside cell view#2900
Merged
Geliogabalus merged 3 commits intoclientIO:masterfrom May 19, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves the HighlighterView behavior by ensuring that highlighting only applies to nodes within the cell view.
- Updated tests verify that nodes outside the DOM are not highlighted.
- Modified the HighlighterView implementation to include a check using cellView.el.contains.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/joint-core/test/jointjs/dia/HighlighterView.js | Adjusted test assertions to confirm the update behavior when nodes are detached from the DOM and the handling of the dirty flag. |
| packages/joint-core/src/dia/HighlighterView.mjs | Added a condition to ensure that a node is only highlighted if it is a valid SVGElement within the cell view. |
9342738 to
1203b58
Compare
Geliogabalus
approved these changes
May 19, 2025
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.
Description
When a highlighter is used with an
SVGElementas its NodeSelector, and that element is not part of theCellView, the node will not be highlighted. Instead, acell:highlighter:invalidevent is triggered—similar to what happens with a non-existent selector.Motivation and Context
When a port is highlighted using an
SVGElementselector and its attributes are updated, we need to make the highlighter invalid. This is because ports are re-rendered on each update, and the originalSVGElementis removed from the DOM. The problem manifest during link reconnection, when the use set port attributes onlink:connectevent.Note: This issue does not occur when using a JSON-based selector.