From 9444135ff5fe5e6929fc945ad0f40d77ca17c340 Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Sat, 12 Feb 2022 06:00:24 +0100 Subject: [PATCH] Fix source code line highlighting (#18729) Co-authored-by: wxiaoguang --- web_src/js/features/repo-code.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web_src/js/features/repo-code.js b/web_src/js/features/repo-code.js index cc3019c236..82ab902ce1 100644 --- a/web_src/js/features/repo-code.js +++ b/web_src/js/features/repo-code.js @@ -16,11 +16,14 @@ function selectRange($list, $select, $from) { const $issue = $('a.ref-in-new-issue'); const $copyPermalink = $('a.copy-line-permalink'); - if ($issue.length === 0 || $copyPermalink.length === 0) { + if ($copyPermalink.length === 0) { return; } - const updateIssueHref = function(anchor) { + const updateIssueHref = function (anchor) { + if ($issue.length === 0) { + return; + } let href = $issue.attr('href'); href = `${href.replace(/%23L\d+$|%23L\d+-L\d+$/, '')}%23${anchor}`; $issue.attr('href', href);