Skip to content
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

Refactor function to process mention tags #6826

Merged
merged 1 commit into from
Feb 14, 2025
Merged

Conversation

acelaya
Copy link
Contributor

@acelaya acelaya commented Feb 14, 2025

Closes https://github.com/orgs/hypothesis/projects/153/views/1?pane=issue&itemId=97415193

Refactor the renderMentionTags function, which has been renamed to processAndReplaceMentionElements, so that it is more obvious that it has side effects and mutates provided DOM element.

Copy link

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.42%. Comparing base (637be04) to head (824c54d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6826      +/-   ##
==========================================
- Coverage   99.42%   99.42%   -0.01%     
==========================================
  Files         272      272              
  Lines       10451    10446       -5     
  Branches     2503     2507       +4     
==========================================
- Hits        10391    10386       -5     
  Misses         60       60              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

element: HTMLElement,
mentions: Mention[],
): Map<HTMLElement, Mention | InvalidUsername> {
const mentionLinks = element.querySelectorAll('a[data-hyp-mention]');
const unprocessedMentionTags = element.querySelectorAll(
'a[data-hyp-mention]:not([data-hyp-mention-type])',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added the extra :not([data-hyp-mention-type]) condition to the selector, to make sure already processed mentions are not processed again.

@acelaya acelaya force-pushed the refactor-render-mention-tags branch from a4f86ad to 70fbdd3 Compare February 14, 2025 11:31
@acelaya acelaya changed the base branch from mention-popover-content to main February 14, 2025 11:31
@acelaya acelaya marked this pull request as ready for review February 14, 2025 11:32
@acelaya acelaya requested a review from robertknight February 14, 2025 11:32
src/sidebar/components/MarkdownView.tsx Outdated Show resolved Hide resolved
@acelaya acelaya force-pushed the refactor-render-mention-tags branch from 70fbdd3 to 824c54d Compare February 14, 2025 13:35
@acelaya acelaya merged commit 386628e into main Feb 14, 2025
4 checks passed
@acelaya acelaya deleted the refactor-render-mention-tags branch February 14, 2025 13:38
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.

2 participants