MCPcopy Index your code
hub / github.com/refined-github/refined-github / maybeAddIconLegacy

Function maybeAddIconLegacy

source/features/new-or-deleted-file.tsx:19–39  ·  view source on GitHub ↗
(filename: HTMLAnchorElement)

Source from the content-addressed store, hash-verified

17] as const;
18
19function maybeAddIconLegacy(filename: HTMLAnchorElement): void {
20 const list = $optional('ul[aria-label="File Tree"]');
21 if (!list && pageDetect.isCommit()) {
22 // Silence error, single-file commits don't have the file list
23 return;
24 }
25
26 const fileInList = $optional(`[href="${filename.hash}"]`, list);
27 if (!fileInList) {
28 features.unload(import.meta.url);
29 throw new Error('Could not find file in sidebar, is the sidebar loaded?');
30 }
31
32 const icon = $optional(['.octicon-diff-removed', '.octicon-diff-added'], fileInList);
33 if (icon) {
34 // `span` needed for native vertical alignment
35 filename.parentElement!.append(
36 <span className="ml-1 tmp-ml-1">{icon.cloneNode(true)}</span>,
37 );
38 }
39}
40
41function maybeAddIcon(fileHeader: HTMLDivElement): void {
42 const fileLink = $('a', fileHeader);

Callers

nothing calls this directly

Calls 2

cloneNodeMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected