Add copy link and highlight to comments

Opening a comment link expands the revision the comment is in, even if
the link is opened while already on the page, and scrolls to it.

This also fixes scrolling to URL fragments that aren't valid CSS
selectors, such as comment ids starting with a digit.
This commit is contained in:
Brandon Oxendine
2026-10-19 18:02:19 +02:00
committed by Rūdolfs Ošiņš
parent 722a83af54
commit 095b4f2fc0
7 changed files with 184 additions and 5 deletions
+19
View File
@@ -429,3 +429,22 @@ describe("untwemoji", () => {
expect(node.innerHTML).toEqual("ab");
});
});
describe("fragmentId", () => {
test.each([
{ hash: "", expected: undefined },
{ hash: "#", expected: undefined },
{ hash: "#delegate", expected: "delegate" },
{ hash: "delegate", expected: "delegate" },
{
hash: "#0a1b2c3d4e5f60718293a4b5c6d7e8f901234567",
expected: "0a1b2c3d4e5f60718293a4b5c6d7e8f901234567",
},
{ hash: "#caf%C3%A9", expected: "café" },
{ hash: "#%", expected: undefined },
{ hash: "#%zz", expected: undefined },
{ hash: "#%E0%A4%A", expected: undefined },
])("fragmentId($hash) => $expected", ({ hash, expected }) => {
expect(utils.fragmentId(hash)).toEqual(expected);
});
});