Skip to content

Remove jQuery class from the code range selection #30173

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

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions web_src/js/features/repo-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ function getLineEls() {
}

function selectRange($linesEls, $selectionEndEl, $selectionStartEls) {
$linesEls.closest('tr').removeClass('active');
for (const el of $linesEls) {
el.closest('tr').classList.remove('active');
}
Copy link
Member

Choose a reason for hiding this comment

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

Seems a bit unusual to iterate a jQuery collection with for-of, but if it works I can accept it.


// add hashchange to permalink
const refInNewIssue = document.querySelector('a.ref-in-new-issue');
Expand Down Expand Up @@ -72,7 +74,7 @@ function selectRange($linesEls, $selectionEndEl, $selectionStartEls) {
classes.push(`[rel=L${i}]`);
}
$linesEls.filter(classes.join(',')).each(function () {
$(this).closest('tr').addClass('active');
this.closest('tr').classList.add('active');
});
changeHash(`#L${a}-L${b}`);

Expand All @@ -82,7 +84,7 @@ function selectRange($linesEls, $selectionEndEl, $selectionStartEls) {
return;
}
}
$selectionEndEl.closest('tr').addClass('active');
$selectionEndEl[0].closest('tr').classList.add('active');
changeHash(`#${$selectionEndEl[0].getAttribute('rel')}`);

updateIssueHref($selectionEndEl[0].getAttribute('rel'));
Expand Down