Skip to content

Commit

Permalink
Remove jQuery class from the code range selection (#30173)
Browse files Browse the repository at this point in the history
- Switched from jQuery class functions to plain JavaScript `classList`
- Tested the code range selection functionality and it works as before

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
  • Loading branch information
yardenshoham authored Mar 29, 2024
1 parent c9068ef commit 9119934
Showing 1 changed file with 5 additions and 3 deletions.
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');
}

// 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

0 comments on commit 9119934

Please sign in to comment.